Vue3学习笔记(6)-Vue3中的生命周期
Vue3中的生命周期


- Vue3.0中可以继续使用Vue2.x中的生命周期钩子,但有有两个被更名:
beforeDestroy改名为beforeUnmountdestroyed改名为unmounted
- Vue3.0也提供了 Composition API 形式的生命周期钩子,与Vue2.x中钩子对应关系如下:
beforeCreate[页面创建前]===>setup()created[页面创建后]=======>setup()beforeMount[页面挂载前]===>onBeforeMountmounted[页面挂载后]=======>onMountedbeforeUpdate[页面更新前]===>onBeforeUpdateupdated[页面更新后]=======>onUpdatedbeforeUnmount[卸载前]==>onBeforeUnmountunmounted[卸载后]=====>onUnmounted
代码展示:
<script> |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0许可协议。转载请注明来自 肥林の仓库

