# 生命周期
- 去除
beforeCreate与created,使用setup()代替 - 新增
onRenderTracked、onRenderTriggered。类似wathcEffect中的onTrack与onTrigger
| 名称 | 描述 |
|---|---|
| onBeforeMount | 替换beforeMount |
| onMounted | 替换mounted |
| onBeforeUpdate | 替换beforeUpdate |
| onUpdated | 替换updated |
| onBeforeUnmounted | 替换beforeDestroy |
| onUnmounted | 替换destroyed |
| onErrorCaptured | 替换errorCatured |
import { onMounted, watchEffect } from 'vue'
const count = ref(0);
onMounted(() => {
watchEffect(() => {
console.log(count.value)
})
})