鏈接:https://segmentfault.com/a/1190000011486619
https://segmentfault.com/a/1190000011381906
附兩張解釋圖
new Vue()
||
||
||
初始化event和watch
||
||=====> beforeCreate
||
屬性、方法、數據等內容的計算
||
||=====> created
||
存在el選項
||
||
||
不存在template選項
||
||=====> beforeMount
||
創建vm.$el替換el選項
||
||=====> mounted
||
當內容發生更新
||
||=====> beforeUpdate
||
虛擬DOM重新渲染
||
||=====> updated
||
調用vm.$destroy()
||
||=====> beforeDestroy
||
卸載watcher、子組件和事件監聽=====> destroyed