生命周期 从无到有 从有到无
created 实例已经创建了
beforeCompile 在实例编译之前
compiled 在实例编译之后执行
ready 实例已经插入到文档之中
beforeDestroy 在销毁之前
destroyed 在销毁之后
知识点:自定义指令执行是在实例编译执行之前
var v = new Vue({
el:"body",
data:{
msg:'hello vue!'
},
created(){
console.log('实例已经创建了')
},
beforeCompile(){
console.log('在实例编译之前')
},
compiled(){
console.log('在实例编译之后执行')
},
ready(){
console.log('实例已经插入到文档之中')
//可以理解成window.onload','jquery ready
},
beforeDestroy(){
console.log('在销毁之前')
},
destroyed(){
console.log('在销毁之后')
}
});