轉一個前端框架VUE-對象生命週期好文章

鏈接: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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章