Offer to come, dig friends take it! I am participating in the 2022 Spring Recruit Punch card activity. Click here for details.

What is the life cycle

A Vue instance has a full life cycle, that is, from the start of creation, initialization of data, compilation of templates, Dom mounting -> render, update -> render, uninstall, etc. We call this the life cycle of a Vue.

The role of each life cycle

The life cycle describe
beforeCreate When a component instance is created, before its properties take effect
created The component instance is fully created and the properties are bound, but the real DOM is not yet generated and $EL is not yet available
beforeMount Called before the mount begins: The associated render function is called for the first time
mountedel Is replaced by the newly created vm.$el and mounted to the instance
beforeUpdate Called before component data is updated and occurs before the virtual DOM is patched
update After the component data is updated
activited Keep-alive is exclusive and is called when the component is activated
deadctivated Keep-alive is exclusive and is called when a component is destroyed
beforeDestory Called before component destruction
destoryed Called after component destruction

Life cycle diagram

Which hook functions are triggered the first time a page is loaded? (will ask)

When the page first page load triggered when beforeCreate, created, beforeMount, mounted the hook function

In which lifecycle is an asynchronous request appropriate to invoke?

An asynchronous request for an official instance is invoked in the Mounted lifecycle, but can actually be invoked in the Created lifecycle as well

DOM rendering is completed in that lifecycle phase

DOM rendering is completed in the Mounted cycle. Execute it once. You can execute it multiple times in the run phase

A front end small white, if the article has the wrong content, welcome big guy to give directions to discuss!