Common usage of hook functions
Data data can be manipulated in the Created hook, and an Ajax request can be made to assign the returned data to data. Although the updated function is triggered when data changes, it cannot accurately determine which attribute value is changed. Therefore, use computed or match functions to monitor attribute changes and perform other operations. Mounted hooks operate on the mounted DOM, which has already been rendered to the page. Created hooks are not invoked repeatedly when vue-Router is used to cache component state. If a child component needs to do something every time it loads or switches state, the Activated hook can be used. All lifecycle hooks automatically bind this context to the instance, so you can’t use arrow functions to define a lifecycle method (e.g. Created: () => this.fetchtodos ()). This causes this to point to the parent.
summary
- Loading the rendering process
Parent beforeCreate-> Parent created-> parent beforeMount-> child beforeCreate-> child created-> child beforeMount-> Child Mounted -> parent Mounted
- Child component update process
Parent beforeUpdate-> Child beforeUpdate-> Child updated-> Parent updated
- Parent component update process
Father father beforeUpdate - > updated
- Destruction of the process
Parent beforeDestroy-> Child beforeDestroy-> Child destroyed-> Parent destroyed