Vue3 - 生命周期钩子函数(组合式 API)

前言

Vue 是组件化编程,从一个组件诞生到消亡会经历很多过程,这些过程就叫做生命周期。而伴随着生命周期,给用户使用的函数,就叫钩子函数,实际为操控生命周期。

本文主要对比 Vue2 生命周期,引出并展开 Vue3 生命周期的介绍,最后做一下整体的总结。

如果您仅需要速览,请查阅如下表格:

Vue2.X (选项式 API) Vue3.X (组合式 API)
beforeCreate setup()
created setup()
beforeMount onBeforeMount
mounted onMounted
beforeUpdate onBeforeUpdate
updated onUpdated
beforeUnmount onBeforeUnmount
unmounted onUnmounted
errorC

你可能感兴趣的:(+,Vue3,Vue3.0,vue3.js,生命周期,组合式API,钩子函数详细教程)