Vue2和Vue3生命周期的对比

Vue2和Vue3生命周期的对比

  • [Vue2 和 Vue3 生命周期对照表](#Vue2 和 Vue3 生命周期对照表)
  • [Vue2 和 Vue3 生命周期图示](#Vue2 和 Vue3 生命周期图示)

Vue2 和 Vue3 生命周期对照表

|------------------|---------------|-------------------|
| 触发时机 | Vue2.x | Vue3.x |
| 组件创建时运行 | beforeCreate | setup |
| 组件创建时运行 | created | setup |
| 挂载在DOM时运行 | beforeMount | onBeforeMount |
| 挂载在DOM时运行 | mounted | onMounted |
| 响应数据修改时运行 | beforeUpdate | onBeforeUpdate |
| 响应数据修改时运行 | updated | onUpdated |
| 元素销毁前执行 | beforeDestroy | onBeforeUnmount |
| 元素销毁前执行 | destroyed | onUnmounted |
| 管理Keep-Alive组件 | activated | onActivated |
| 管理Keep-Alive组件 | deactivated | onDeactivated |
| Vue3 Debug Hooks | - | onRenderTriggered |
| Vue3 Debug Hooks | - | onRenderTracked |

Vue2 和 Vue3 生命周期图示

  1. Vue2 生命周期图

  2. Vue3 生命周期图

相关推荐
geovindu19 分钟前
CSharp: Iterative Algorithms
开发语言·后端·算法·c#·.net·迭代算法
一只月月鸟呀35 分钟前
移动端tap与click的区别 && 点透事件
开发语言·前端·javascript
雨落在了我的手上36 分钟前
Java数据结构(六):链表的介绍
java·开发语言·数据结构
影寂ldy38 分钟前
C# HttpClient 分片下载、断点续传、暂停取消(完整项目知识点)
开发语言·c#
独隅44 分钟前
DevEco Code Plan+Build 双 Agent 协同开发效率实测
java·开发语言
KaMeidebaby2 小时前
卡梅德生物技术快报|抗体筛选:抗体筛选中的噬菌体展示四参数调优——从流程设计到数据验证
开发语言·前端·javascript
大黄说说2 小时前
接口频繁超时、报错?后端常见排查思路总结
开发语言·php
跨境小陈2 小时前
2026 年如何使用 Python 抓取 Reddit 数据
开发语言·网络·python
默_笙2 小时前
🔑 让 AI 学会"读"网页:我用 Cheerio 爬了一篇掘金文章,然后切成小块存进了向量库
前端·javascript
dtq04242 小时前
C语言-文件操作1
c语言·开发语言·学习