vue3 | vue2 |
|---|---|
setup() 开始创建组件 | beforeCreate() + created() |
onBeforeMount() 组件挂载到页面之前 | beforeMount() |
onMounted() 组件挂载到页面之后 | Mounted() |
onBeforeUpdate() 组件更新之前 | beforeUpdate() |
onUpdated() 组件更新之后 | updated() |
onBeforeUnmount() 组件卸载之前 | beforeDestroy() |
onUnmount() 组件卸载之前 | destroyed() |
<keep-alive></keep-alive>使用时,增加的生命周期 | |
onActivated() | activated() |
onDeactivated() | deactivated() |
注: 钩子函数必须写在setup() 里面,vue3生命周期都先于对应的vue2生命周期执行。

1. Object.defineProperty的缺点
2. Proxy实现响应式
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。