Vue 的?組件和?組件?命周期鉤?執(zhí)?順序是什么?

渲染過程:
?組件掛載完成?定是等?組件都掛載完成后,才算是?組件掛載完,所以?組件的mounted在?組 件mouted之后。

?beforeCreate -> ?created -> ?beforeMount -> ?beforeCreate -> ?created -> ?beforeMount -> ?mounted -> ?mounted

?組件更新過程:

  1. 影響到?組件: ?beforeUpdate -> ?beforeUpdate->?updated -> ?updted
  2. 不影響?組件: ?beforeUpdate -> ?updated

?組件更新過程:

  1. 影響到?組件: ?beforeUpdate -> ?beforeUpdate->?updated -> ?updted
  2. 不影響?組件: ?beforeUpdate -> ?updated

銷毀過程:
?beforeDestroy -> ?beforeDestroy -> ?destroyed -> ?destroyed

父級組件中如果在子級組件上加個(gè)v-if判斷,父組件更新數(shù)據(jù)使條件達(dá)成展示組件,條件達(dá)成時(shí):
父 beforeUpdate ->子 beforeCreate ->子created ->子 beforeMount ->子 mounted ->父 updated

看起來很多好像很難記憶,其實(shí)只要理解了,不管是哪種情況,都?定是?組件等待?組件完成后,才 會執(zhí)???對應(yīng)完成的鉤?,就可以很容易記住。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容