四、组件的生命周期

发布时间 2023-04-20 16:01:20作者: 前端混子Ray
import { onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted} from "vue"
1、onBeforeMount创建
onBeforeMount(()=>{
        // 创建之前
    })
    onMounted(()=>{
        // 创建完成
    })
2、onBeforeUpdate更新
onBeforeUpdate(()=>{
        // 更新之前
    })
    onUpdated(()=>{
        // 更新完成
    })
3、onBeforeUnmount销毁
// v-if会触发组件销毁生命周期
    onBeforeUnmount(()=>{
        // 销毁之前
    })
    onUnmounted(()=>{
        // 销毁完成
    })