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 生命周期图

相关推荐
Julien2004几秒前
管理机密(一)
运维·服务器·开发语言·学习方法
Chen_harmony3 分钟前
七、STL与string类
开发语言·c++
沐晓时光10 分钟前
C语言入门,字符串和字符串函数知识讲解
c语言·开发语言
xxxiugou12329 分钟前
C++命名空间与引用全解析
开发语言·c++
独隅1 小时前
WebStorm Windows 版 React / Next.js 实战替换指南
javascript·windows·webstorm
冷眸_1 小时前
同名食材不能直接相减:一个 JavaScript 用量模型的边界
javascript
apollo_qwe1 小时前
接口超时了,前端为什么不能直接重试?
javascript·http
yangmu32032 小时前
编程语言发展简史:从机器指令到智能协作
开发语言
Pniubi4 小时前
Java为什么要分堆和栈
java·开发语言
小小晓.5 小时前
Qt 对话框、QLineEdit 与布局管理实战详解
开发语言·qt