Vue life cycle process

 The process from creation to destruction of a Vue instance is the "life cycle". Each component or Vue instance goes through a complete life cycle, starting from creation, initializing data, compiling templates, mounting dom, rendering-update-rendering, destruction and a series of processes. It is divided into three stages: initialization, Running, destroyed.

  Life cycle hook function:

life cycle hooks detailed
beforeCreated After the instance is initialized, data data observation and event and watch event configurations are not initialized and are called before initialization.
created Called after the instance has been created. Data data observation, property and method operations, event and watch event callbacks have been completed. The mounting has not started yet, and the $el attribute is not visible.
beforeMount Called before mounting, data and el ** have been initialized, but ** el** have been initialized, but **he _have been initialized, but elis not rendered into data, and the value is a virtual element node.
mounted el is replaced by the newly created vm.$el, which is called after rendering is completed and mounted on the instance.
beforeUpdate Called when the data is updated, before the virtual DOM is re-rendered. It is possible to further change the state in this hook, which will not trigger an additional re-rendering process.
updated Data changes cause the virtual dom to be re-rendered, after which this hook function is called. This hook is called when the dom has been updated.
activated Called when the keep-alive component is activated.
deactivated Called when the keep-alive component is deactivated.
beforeDestroy Called before the instance is destroyed. The instance is still fully available at this step.
destroyed Called after the Vue instance is destroyed. When called, everything pointed to by the Vue instance will be unbound, all event listeners will be removed, and all child instances will be destroyed.

Note: Except for the beforeCreate and created hooks, other hooks are not called during server-side rendering.

 Life cycle diagram:
life cycle diagram
Reference link: Vue series - Detailed explanation of Vue life cycle

Guess you like

Origin blog.csdn.net/weixin_42132439/article/details/126648963