vue生命周期 钩子函数

beforeCreate:初始化之前

beforeCreate(){
console.log("代码初始化之前")
}

Created:初始化完成

created(){
console.log("初始化完成");
}

beforeMount:挂载之前

beforeMount(){
console.log("挂载之前")
}

mounted:挂载之后

mounted(){
console.log("挂载之后")
}

beforeUpdate:数据更新之前

beforeUpdate(){
console.log("数据更新之前")
}

updated:数据更新之后

updated(){
console.log("更新之后")
}

beforeDestroy:解除绑定之前

beforeDestroy(){
console.log("解除绑定之前")
}

destroyed:解除绑定之后

destroyed(){
console.log("解除绑定之后")
}

解除绑定需要在vue实例之外写解除绑定的方法  vue自己定义好了" $destroy

function del(){
app.$destroy()
}

vue生命周期图示:

vue生命周期 钩子函数