1. 程式人生 > >vue的生命週期鉤子函式與自定義指令鉤子函式

vue的生命週期鉤子函式與自定義指令鉤子函式

Vue.directive('hello',{ bind:function(el){ console.log("bind時父節點為:"+el.parentNode) console.log("觸發bind指令鉤子函式") }, inserted:function(el,binding,vnode){ console.log("inserted時父節點為:"+el.parentNode) console.log("觸發inserted指令鉤子函式"); }, update
:function(el){ console.log("觸發update指令鉤子函式") }, componentUpdated:function(el){ console.log("觸發componentUpdated指令鉤子函式") }, unbind:function(el){ console.log("觸發unbind指令鉤子函式") } }) new Vue({ el:"#app", data:{ msg
:"" }, beforeCreate(){ console.log("beforeCreate") }, created(){ console.log("created") }, beforeMount(){ console.log("beforeMount") }, mounted(){ console.log("mounted") }, beforeUpdate(){ console
.log("BeforeUpdate") }, updated(){ console.log("updated") }, beforeDestroy(){ console.log("beforeDestroy") }, destroyed(){ console.log("destroyed") } })