1. 程式人生 > 其它 >Vuejs學習筆記(一)-5.Vue的生命週期

Vuejs學習筆記(一)-5.Vue的生命週期

Vue物件的生命週期:Vue的 生命週期

以上紅色部分的都是Vue例項建立過程中生命週期的回撥函式。有:beforeCreate,create,bemounted,mounted,destoryed等。以下程式碼是簡單用法:

 1 <!--
 2 @author:invoker
 3 @project:project_lianxi
 4 @file: 03-vue的生命週期.html
 5 @contact:invoker2021@126.com
 6 @descript:
 7 @Date:2021/6/30 19:34
 8 @version: html5
 9 -->
10 
11 <!DOCTYPE html>
12
<html lang="en"> 13 <head> 14 <meta charset="UTF-8"> 15 <title>03-vue的生命週期</title> 16 </head> 17 <body> 18 <div id="app"> 19 20 </div> 21 <script src="../js/vue.js"></script> 22 <script> 23 const app = new Vue({ 24 el:'#app',
25 data:{ 26 message:'hello vuejs' 27 }, 28 //開啟網頁後再console控制檯裡面檢視是否呼叫created方法 29 created(){ 30 console.log('created'); 31 }, 32 destroyed(){ 33 console.log('destroyed'); 34 } 35 }) 36 </script> 37 </body> 38 </html>