首先上图展

 <template>
<div id="home">
<p>{{ message }}</p>
</div>
</template>
<script>
export default{
data(){
return{
message:"vuex is very hard"
}
},
beforeCreate(){
console.log('beforeCreate创建前状态');
console.log("el:"+this.$el);//undefined
console.log("data:"+this.$data);//undefined
console.log("message:"+this.message)//undefined
},
created(){
console.log('created创建完毕状态');
console.log("el:"+this.$el);//undefined
console.log("data:"+this.$data);//[object Object]
console.log("message:"+this.message)//vuex is very hard
},
beforeMount(){
console.log('beforeMount挂载前状态');
console.log("el:"+this.$el);//undefined
console.log("data:"+this.$data);//[object Object]
console.log("message:"+this.message)//vuex is very hard
},
mounted(){
console.log('mounted挂载结束状态');
console.log("el:"+this.$el);//[object HTMLDivElement]
console.log("data:"+this.$data);//[object Object]
console.log("message:"+this.message)//vuex is very hard
},
beforeUpdate(){
console.log('beforeUpdate更新前状态');
console.log("el:"+this.$el);
console.log("data:"+this.$data);
console.log("message:"+this.message)
},
updated(){
console.log('updated更新完成状态');
console.log("el:"+this.$el);
console.log("data:"+this.$data);
console.log("message:"+this.message)
},
beforeDestroy(){
console.log('beforeDestroy摧毁前状态');
console.log("el:"+this.$el);
console.log("data:"+this.$data);
console.log("message:"+this.message)
},
destroyed(){
console.log('destroyed');
console.log("el:"+this.$el);
console.log("data:"+this.$data);
console.log("message:"+this.message)
},
}
</script>

主要:

beforecreated:el 和 data 并未初始化
created:完成了 data 数据的初始化,el没有
beforeMount:完成了 data 数据的初始化,el没有
mounted :完成挂载,完成了 el 和 data 初始化
beforecreate : 可以在这加个loading事件
created :在这结束loading,还做一些初始化,实现函数自执行
mounted : 在这发起后端请求,拿回数据,配合路由钩子做一些事情
beforeDestory: 你确认删除XX吗? destoryed :当前组件已被删除,清空相关内容

参考:https://segmentfault.com/a/1190000008010666

vue2.0生命周期详解的更多相关文章

  1. ASP.NT运行原理和页面生命周期详解及其应用

    ASP.NT运行原理和页面生命周期详解及其应用 1. 下面是我画的一张关于asp.net运行原理和页面生命周期的一张详解图.如果你对具体不太了解,请参照博客园其他帖子.在这里我主要讲解它的实际应用.  ...

  2. ASP.NET生命周期详解

    最近一直在学习ASP.NET MVC的生命周期,发现ASP.NET MVC是建立在ASP.NET Framework基础之上的,所以原来对于ASP.NET WebForm中的很多处理流程,如管道事件等 ...

  3. ASP.NET生命周期详解 [转]

    最近一直在学习ASP.NET MVC的生命周期,发现ASP.NET MVC是建立在ASP.NET Framework基础之上的,所以原来对于ASP.NET WebForm中的很多处理流程,如管道事件等 ...

  4. vue2.0 生命周期 简析

    Vue2.0 生命周期钩子函数: <template> <div id='app'> {{message}} </div> </template> va ...

  5. ASP.NET生命周期详解(转)

    看到好文章需要分享. 最近一直在学习ASP.NET MVC的生命周期,发现ASP.NET MVC是建立在ASP.NET Framework基础之上的,所以原来对于ASP.NET WebForm中的很多 ...

  6. React—组件生命周期详解

    React—组件生命周期详解 转自 明明的博客  http://blog.csdn.net/slandove/article/details/50748473 (非原创) 版权声明:转载请注明出处,欢 ...

  7. vue2.0中router-link详解

    vue2.0中router-link详解:https://blog.csdn.net/lhjuejiang/article/details/81082090 在vue2.0中,原来的v-link指令已 ...

  8. 详解Vue2.0生命周期

    网上已经有很多关于vue生命周期的文章,我的这篇文章的由来,其实是我对官网上描述的一句话的思考与理解:“el被新创建的vm.$el替换”,所以文章更多的内容可能是在对vue生命周期中“created ...

  9. 【转】Java 类的生命周期详解

    一. 引 言 最近有位细心的朋友在阅读笔者的文章时,对java类的生命周期问题有一些疑惑,笔者打开百度搜了一下相关的问题,看到网上的资料很少有把这个问题讲明白的,主要是因为目前国内java方面的教材大 ...

随机推荐

  1. React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

    昨天在项目中,重新封装组件时,引用了原来的一个子组件,但发现子组件在其他页面正常,在新的组件里面就发生保存, 然后把子组件注释,随便显示其div元素也正常,纠结了很久,最后发现引用的方式有问题 子组件 ...

  2. C# 图像处理:记录图像处理时间的一个类

    class HiPerTimer { [DllImport("user32.dll")] static extern bool GetLastInputInfo(ref LASTI ...

  3. CMake Error at cmake/OpenCVUtils.cmake

    CMake Error at cmake/OpenCVUtils.cmake:1047 (message): Failed to download . Status= Call Stack (most ...

  4. Dapper使用总结

  5. js高级-作用域链

    作用域链存放的就是 VO  AO 参数 变量 等

  6. Linux 安装 iptables防火墙

    CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables st ...

  7. numpy中的数学

    1.dot,exp v = np.dot(arg1,arg2) #矩阵乘法 v2 = np.exp() # e的-x 次方

  8. linux删除历史操作命令

    有时候在系统中做了任何操作,但不想被别人知道,毕竟系统别人都可以登入查看,那怎么把自己操作系统的历史命令删除而不让别人知晓呢? 在linux系统里一旦操作了任何命令,都会被记录下来,可以通过histo ...

  9. 物料没加DUMMY

    会加入DUMMY的表 IN_ITEM,IN_ITEM_SITE,IN_SALES_ORDER 加入DUMMY的存储过程名为SAP_MATERIAL_SO. FP_CHANGE_MO_ROUTING的第 ...

  10. SQLMAP自动注入(二)

    --data 添加post头 --data 添加get头 --cookie 添加cookie 设置探测级别大于等于2时会探测cookie是否有注入点 --random-agent 随机生成user-a ...