Vue 生命周期

beforeCreate :组件实例刚刚被建立,属性都尚未vue

created:实例已经建立完成,属性已经绑定app

beforeMount:模板编译以前spa

mounted:模板编译z以后ip

beforeUpdate:组件更新以前io

updated:组件更新完毕console

beforeDestroy:组件销毁前编译

destroyed:组件销毁后function

---------------------------------------------------------------------------------------------------------模板

  <div id="app"></div>date

<script>

  var app=new Vue({

  el:'#app',

  beforeCreate:function(){

    console.log('实例刚刚被建立');

  },

  craeted:function(){   //*****经常使用

    console.log('实例属性能够使用了');

  },

  beforeMount:function(){

    console.log('实例被挂载以前');

  },

  mounted:function(){   //*****经常使用

    console.log('挂载成功,而且模板数据编译成功');

  },

  beforeUpdate:function(){   //数据点击就改变

    console.log('数据更新以前');

  },

  updated:function(){

    console.log('数据更新完成');

  },

  beforeDestroy:function(){

    console.log('实例销毁以前');

  },

  destroyed:function(){    //vue不会本身销毁

    console.log('实例销毁以后');

  }

})

</script>

相关文章
相关标签/搜索