vue实例生命周期
2024-10-15 06:20:37
实例生命周期
var vm = new Vue({
data: {
a: 1
},
created: function () {
// `this` 指向 vm 实例
console.log('a is: ' + this.a)
}
})
// -> "a is: 1"
|
There are also other hooks which will be called at different stages of the instance’s lifecycle, for example mounted
, updated
, and destroyed
. All lifecycle hooks are called with their this
context pointing to the Vue instance invoking it. You may have been wondering where the concept of “controllers” lives in the Vue world and the answer is: there are no controllers. Your custom logic for a component would be split among these lifecycle hooks.
也有一些其它的钩子,在实例生命周期的不同阶段调用,如 mounted
、 updated
、destroyed
。钩子的 this
指向调用它的 Vue 实例。一些用户可能会问 Vue.js 是否有“控制器”的概念?答案是,没有。组件的自定义逻辑可以分布在这些钩子中。
生命周期图示
下图说明了实例的生命周期。你不需要立马弄明白所有的东西,不过以后它会有帮助。
最新文章
- HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
- Enabling Cross-Origin Requests in ASP.NET Web API 2
- ubuntu1404服务器版中设置root用户
- main函数的argc和argv
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- 结对开发--课堂练习--c++
- Redis与Memcached的incr/decr差异对比
- EffectiveC#02--仅在对基类进行强制更新时才使用new修饰符
- 一个关于css3背景透明的例子
- lucene4.4 索引的增删改查
- Linux使用rsync客户端与服务端同步目录进行备份
- [android游戏开发初学]SurfaceView初探之缓冲区测试
- 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动 8×8 点阵
- openstack-ocata-计算服务4
- /etc/shadow中密码段的生成方式
- Uva 11178 Morley定理
- [openjudge-动态规划]鸣人的影分身
- 微信小程序倒计时组件开发
- kafka 支持发布订阅
- js实现获取URL参数