# 生命周期

  • 去除beforeCreatecreated,使用setup()代替
  • 新增onRenderTrackedonRenderTriggered。类似wathcEffect中的onTrackonTrigger
名称 描述
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) 
  })
})