vue 的生命週期實例

1、在test.vue文件內寫好dom結構;
2、在script標籤內寫好beforeCreate(創建前),created(創建後),beforeMount(載入前),mounted(載入後),beforeUpdate(更新前),updated(更新後),beforeDestroy(銷燬前),destroyed(銷燬後);
3、在methods裏寫好change方法。

這裏寫圖片描述
這裏寫圖片描述

4、刷新頁面,執行結果如下圖:
這裏寫圖片描述

5、點擊div,觸發change方法:
這裏寫圖片描述

6、離開當前頁面或者刷新當前頁面之前,開始執行銷燬前和銷燬後的鉤子函數。
這裏寫圖片描述