vue生命周期钩子函数
vue中的生命周期【钩子函数详细用法】
beforeCreate:初始化之前
beforeCreate(){
console.log('1-beforeCreate 初始化之前');
}
created:初始化完成
created(){
console.log('created初始化完成');
}
beforeMount:挂载之前
beforeMount(){
console.log('beforeMount挂载之前');
}
mounted:挂载完成之后
mounted(){
console.log('mounted挂载完成之后');
},
beforeUpdate:数据更新之前
beforeUpdate(){
console.log('beforeUpdate数据更新前');
},
update:数据更新之后
updated(){
console.log('updated数据更新之后');
},
beforeDestroy:解除绑定之前
beforeDestroy(){
console.log('beforeDestroy解除绑定之前');
},
destroyed:解除绑定之后
destroyed(){
console.log('destroyed 解除绑定之后')
}
注:解除绑定需要在vue实例之外写解除绑定的方法vue自己给定义好了".$destroy"
function del() {
// 解除绑定
app.$destroy();
}
附:vu生命周期图示e