Options / Lifecycle Hooks

Options / Lifecycle Hooks

All lifecycle hooks automatically have their this context bound to the instance, so that you can access data, computed properties, and methods. This means you should not use an arrow function to define a lifecycle method (e.g. created: () => this.fetchTodos()). The reason is arrow functions bind the parent context, so this will not be the Vue instance as you expect and this.fetchTodos will be undefined.
beforeCreate

Type: Function

Details:

Called synchronously immediately after the instance has been initialized, before data observation and event/watcher setup.

See also: Lifecycle Diagram
Published 133 original articles · praised 189 · 10,000+ views

Guess you like

Origin blog.csdn.net/blog_programb/article/details/105603570