vue生命周期钩子

 
var vm = new Vue({
el: "#app",
data: {
msg:'还没初始化呢'
 
},
methods: {
show() {
console.log('我也没初始化呢');
}
},
beforeCreate() {                  //实例初始化完成,但数据还是没有                           
console.log(this.msg);
this.show()
}, 
created () {                         //数据初始化完成,可以调用了,data和methods
console.log(this.msg);
this.show()
},
created () {                         //数据初始化完成,可以调用了,data和methods了,但模板还在内存里没渲染,除了莫模板都能用
console.log(this.msg);
this.show()
},
mounted () {                         //数据初始化完成,可以调用了,data和methods了,模板也渲染完成了,完事,都能用了
console.log(this.msg);
this.show()
}
});
 

 

posted @ 2019-06-04 14:39  一只大鹅  阅读(155)  评论(0编辑  收藏  举报