1. 加載渲染過程
- 同步引入時生命周期順序為:
父組件的beforeCreate、created顽分、beforeMount --> 所有子組件的beforeCreate席揽、created、beforeMount --> 所有子組件的mounted --> 父組件的mounted
總結(jié):父組件先創(chuàng)建薪贫,然后子組件創(chuàng)建;子組件先掛載已卸,然后父組件掛載
若有孫組件呢?
父組件先beforeCreate => created => beforeMount , 然后子組件開始beforeCreate => created => beforeMount 硼一,然后孫組件beforeCreate => created => beforeMount => mounted累澡,孫組件掛載完成了,子組件mounted般贼,父組件再mounted
-
異步引入時生命周期順序為:
父組件的beforeCreate愧哟、created、beforeMount哼蛆、mounted --> 子組件的beforeCreate蕊梧、created、beforeMount腮介、mounted總結(jié):父組件創(chuàng)建肥矢,父組件掛載;子組件創(chuàng)建叠洗,子組件掛載甘改。
2. 子組件更新過程
父beforeUpdate->子beforeUpdate->子updated->父updated
3.父組件更新過程
父beforeUpdate->父updated
4.銷毀過程
父beforeDestroy->子beforeDestroy->子destroyed->父destroyed