生命周期函数:
v2:
beforeCreate
created
beforeMount
mounted
beforeUpdate
updated
beforeDestroy
destroyed
activated
deactivated
errorCaptured
v3:
setup--》替换掉 beforeCreate 之前执行
onBeforeMount
onMounted
onBeforeUpdate 更新前
onUpdated 更新后
onBeforeUnMount //销毁前
onUnmounted //销毁后
activated
deactivated
errorCaptured
知识点扩展:
相比较于vue2,vue3中新增两个全新钩子函数
1.onRenderTracked函数:当组件渲染过程中追踪到响应式依赖时调用。
2.onRenderTriggered函数:当响应式依赖的变更触发组件渲染时调用。