生命周期.png
以下代码,测试生命周期函数在各种情况下是否被调用
beforeCreate(){
console.log("==beforeCreate==");
console.log(this.$el);
console.log(this.$data);
},
created(){
console.log("==created==");
console.log(this.$el);
console.log(this.$data);
},
beforeMount(){
console.log("==beforeMount==");
console.log(this.$el);
console.log(this.$data);
},
mounted(){
console.log("==mounted==");
console.log(this.$el);
console.log(this.$data);
},
beforeUpdate(){
console.log('=beforeUpdate=');
console.log(this.$el);
console.log(this.$data);
},
updated(){
console.log('==updated==');
console.log(this.$el);
console.log(this.$data);
},
beforeDestory(){
console.log("==beforeDestory==");
},
destoryed(){
console.log("==destoryed==");
}
网友评论