生命周期原创
# 生命周期
# 介绍
- 与Vue2基本相同
- beforeDestory改为beforeUnmount
- destoryed改为unmounted
# 以配置项方式使用
- beforeCreate ————>
- created ————>
- beforeMount ————>
- mounted ————>
- beforeUpdate ————>
- updated ————>
- beforeUnmount ————>
- unmounted ————>
# 以组合式API方式使用
- setup ————>相当于beforeCreate
- steup ————>实际执行时机先于beforeCreate
- onBeforeMount
- onMounted
- onBeforeUpdate
- onUpdated
- onBeforeUnmount
- onUnmounted
# 注意点
- 配置项形式使用时,生命周期钩子为函数,直接在函数内部书写逻辑
- 组合式API形式使用时,生命周期钩子为方法,接受一个处理逻辑的(箭头函数)函数作为参数。
- 当两者对应的钩子同时使用时,组合式API更快一点