1. Brief description: In Vue, each component goes through a life cycle from loading to rendering: create, initialize, mount, update, destroy. The hook function is divided into eight parts beforeCreate Created beforeMount Mounted beforeUpdate updated beforeDistory distoryed
2. Hook function usage:
1) beforeCreate: at this time, the node of the component is not created, and the data and methods properties are not initialized. 2) Created: The component’s data and methods have been created, but the template has not been compiled. In Created, you can do call interface operations, such as getting data from a rendered tableParameters that can accept route transmission:If you want to get tag attributes by ID or ref, you can do so through the this.$nextTick callback
- BeforeMounted: A template is compiled but not rendered to a page. The actions that can be performed are similar to created.
4) Mounted: A DOM node is successfully mounted.
5) beforeUpdate: Execute this function before updating, the state in data is already up to date, but the page is not rendered and the effect is not displayed.
6) Updated: The page is updated. Updated is similar to comptued and Watch, and can be used to monitor data changes. For example, the updated listens for the specified password
7) beforeDestroy: Called before component destruction. At this step, it’s still completely available.
8) Destroyed: called after the Vue instance is destroyed. When called, everything indicated by the Vue instance is unbound, all event listeners are removed, and all subinstances are destroyed.