深入了解vue2与vue3的生命周期对比
作者:新时代农民工Top 时间:2024-05-11 09:14:32
目录
周期对比
用法
总结
周期对比
vue2 | vue3 |
---|---|
beforeCreate | setup |
created | setup |
beforeMount | onBeforeMount |
mounted | onMounted |
beforeUpdate | onBeforeUpdate |
updated | onUpdated |
activeted | onActiveted |
deactiveted | onDeactiveted |
beforeDestory | onBeforeUnmount |
destoryed | onUnmounted |
用法
vue2 中的生命周期与 data / methods 同级别以函数方式使用,比如 created() {}
data() {
return {}
},
created() {
...
}
vue3 中的生命周期 setup 在最外层,不需要按需加载,其他的生命周期得按需加载才能使用
import { omMounted } from 'vue'
setup() {
onMounted(() => { ... })
}
总结
本篇文章就到这里了,希望能够给你带来帮助,也希望您能够多多关注asp之家的更多内容!
来源:https://blog.csdn.net/web00_11/article/details/121968683
标签:vue,生命周期
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
pandas.DataFrame 根据条件新建列并赋值的方法
2022-09-06 05:51:05
用asp实现读取文件的最后一行的代码
2011-03-08 10:55:00
使用 pytorch 创建神经网络拟合sin函数的实现
2023-02-04 03:31:40
![](https://img.aspxhome.com/file/2023/3/94163_0s.png)
Vue.js 加入高德地图的实现代码
2024-05-28 15:51:31
![](https://img.aspxhome.com/file/2023/0/123160_0s.png)
简单易懂的python环境安装教程
2023-05-21 14:39:16
![](https://img.aspxhome.com/file/2023/6/90436_0s.png)
详尽解析javascript的event对象
2008-01-16 11:27:00
uniapp组件uni-popup弹出层的使用
2024-04-28 09:47:55
![](https://img.aspxhome.com/file/2023/7/132767_0s.gif)
mysql的case when字段为空,null的问题
2024-01-13 14:40:59
wxpython中Textctrl回车事件无效的解决方法
2021-10-16 23:00:07
如何使用 Go 和 Excelize 构建电子表格
2024-02-10 04:59:02
JS中的forEach、$.each、map方法推荐
2024-04-29 13:19:59
python爬虫开发之Beautiful Soup模块从安装到详细使用方法与实例
2023-12-09 06:16:18
![](https://img.aspxhome.com/file/2023/1/92091_0s.png)
Python通过zookeeper实现分布式服务代码解析
2021-09-11 11:09:48
python自带的http模块详解
2021-11-03 08:59:22
Django 如何使用日期时间选择器规范用户的时间输入示例代码详解
2023-06-18 23:56:20
![](https://img.aspxhome.com/file/2023/1/64321_0s.gif)
19个MySQL性能优化要点解析
2024-01-18 16:03:14
用IE浏览器UTF-8页面是一片空白
2009-06-14 19:55:00
使用ASP常见问题解答
2007-10-11 14:07:00
PDO::_construct讲解
2023-06-06 03:22:31
SQL Server 2005日志文件损坏的处理方法
2008-12-02 14:36:00