vue生存周期
来源:互联网 发布:包小姐过夜 知乎 编辑:程序博客网 时间:2024/05/12 02:29
生存周期
<div id="app"> <p>{{ message }}</p></div><script type="text/javascript"> var app = new Vue({ el: '#app', data: { message : "xuxiao is boy" }, beforeCreate: function () { console.group('beforeCreate 创建前状态===============》'); console.log("%c%s", "color:red" , "el : " + this.$el); //undefined console.log("%c%s", "color:red","data : " + this.$data); //undefined console.log("%c%s", "color:red","message: " + this.message) }, created: function () { console.group('created 创建完毕状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); //undefined console.log("%c%s", "color:red","data : " + this.$data); //已被初始化 console.log("%c%s", "color:red","message: " + this.message); //已被初始化 }, beforeMount: function () { console.group('beforeMount 挂载前状态===============》'); console.log("%c%s", "color:red","el : " + (this.$el)); //已被初始化 console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); //已被初始化 console.log("%c%s", "color:red","message: " + this.message); //已被初始化 }, mounted: function () { console.group('mounted 挂载结束状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); //已被初始化 console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); //已被初始化 console.log("%c%s", "color:red","message: " + this.message); //已被初始化 }, beforeUpdate: function () { console.group('beforeUpdate 更新前状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); console.log("%c%s", "color:red","message: " + this.message); }, updated: function () { console.group('updated 更新完成状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); console.log("%c%s", "color:red","message: " + this.message); }, beforeDestroy: function () { console.group('beforeDestroy 销毁前状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); console.log("%c%s", "color:red","message: " + this.message); }, destroyed: function () { console.group('destroyed 销毁完成状态===============》'); console.log("%c%s", "color:red","el : " + this.$el); console.log(this.$el); console.log("%c%s", "color:red","data : " + this.$data); console.log("%c%s", "color:red","message: " + this.message) } })</script>
chrome浏览器 打印的console出来的数据
当你手动改变data里面的值时,beforeUpdate,updated两个函数才会执行
关于催毁
beforeDestroy
destroyed
这两个执行app.$destroy()时 ,才会执行的两个函数
自己复制运行一下就很好理解了~~
参考:https://segmentfault.com/a/1190000008010666
0 0
- vue生存周期
- 页面生存周期
- 软件生存周期
- .net页面生存周期
- aspx页面生存周期
- 页面的生存周期
- 页面的生存周期
- 页面的生存周期
- 页面生存周期
- 生存周期中的指针
- 组件生存周期
- 页面生存周期-心得
- JavaBean的生存周期
- .net页面生存周期
- 软件生存周期
- 页面生存周期
- sevlet的生存周期
- 软件生存周期
- 关于eternal blue virus的预防操作及相关知识
- 通过一个例子说说主动装箱和Integer缓存
- 经典编程书籍大全
- MySQL数据库学习日志5.15
- Android纯的二维码扫描界面和功能-zxing
- vue生存周期
- AngularJS学习笔记--使用angular.extend()实现工厂模式
- Redis高级实用特性(持久化机制、发布订阅消息、虚拟内存的使用)
- xshell接linux服务器
- Zookeeper系列(三十)Zookeeper场景应用之配置管理中心
- Android EditText达到SearchView的效果
- FFMPEG学习【libavcodec】:发送/接收编码和解码API概述
- ubuntu下sublimetext3输入中文的方法
- 【剑指offer】重建二叉树