current position:Home>Front end framework Vue - life cycle

Front end framework Vue - life cycle

2022-01-27 00:18:04 laufing

What is life cycle

Vue The life cycle of is some callback functions executed at a specific time , Have a fixed name , The content is written by yourself .
this Point to Vue Instance or component instance

Life cycle function

beforeCreate; When creating data monitoring 、 Before the data broker .
created; Just finished data monitoring 、 Data brokers .
beforeMount; Creating reality DOM
mounted; Create reality DOM, And mount the page to complete ,
Usually set the timer here , Send network request , The binding event , Subscribe to news, etc ; Commonly used

beforeUpdate; Before updating , The data is new , But the page is old
updated; Just finished updating , The data is new , The page is new

 
vm.$destroy() The destruction Vue example
beforeDestroy; Before starting destruction , Cancel the timer here , Unbind custom events , Unsubscribe, etc . No longer manipulate data , The operation does not update . Commonly used

Destroy the monitor 、 Child components 、 Event monitoring
destroyed ; Just finished destroying

Use cases

Timer

copyright notice
author[laufing],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270018031434.html

Random recommended