首先上图展

 <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. Shell编程常用函数

    1.打印提示消息函数,不同级别消息使用不同的颜色显示.其中错误信息提示为红色字体. # -------------------------------------------------------- ...

  2. 利用官方的vue-cli脚手架来搭建Vue集成开发环境

    在利用vue-cli脚手架搭建vue集成环境之前,我们需要先安装nodejs的环境.如果在cmd中输入node --version和npm --version出现如下的版本信息,就说明安装已经成功了. ...

  3. flume 详细介绍

    http://blog.csdn.net/a2011480169/article/details/51544664 配有详细的例子. http://www.cnblogs.com/gongxijun/ ...

  4. python 验证码test

    灰度化 #coding:utf8 import re import urllib import urllib2 import requests from PIL import Image import ...

  5. eclipse调试快捷键

    Eclipse中有如下一些和运行调试相关的快捷键. 1. [Ctrl+Shift+B]:在当前行设置断点或取消设置的断点.    2. [F11]:调试最后一次执行的程序.    3. [Ctrl+F ...

  6. winform,listbox设置行高

    //必须要在写这个事件里写才有效果 private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e) { e.ItemH ...

  7. tomcat 启动脚本

    #!/bin/bash##干掉运行中的tomcat  results=把结果赋值给变量,可以保证命令上条执行完再执行下一条#也可以用这句简单的代码按进程名kill: ps -ef | grep 进程名 ...

  8. ubuntu18换国内源

    编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份): ##中科大源 deb https://mirrors.ustc.edu.cn/ubuntu/ ...

  9. cd-hit软件

    参考网址:https://www.jianshu.com/p/57af07b9e986 1.安装 wget https://github.com/weizhongli/cdhit/releases/d ...

  10. session of express

    [session of express] 1.express-session 一个提供session功能库 npm install express-session --save var session ...