vue3-component

<component v-if="showable" :is="dialog" :message="trans_data" />
通过component呈现的子组件,在父组件卸载前不会卸载,可通过v-if强制卸载

<template>
  <div v-if="isComponentAlive">
    <!-- 你的组件内容 -->
  </div>
</template>
 
<script setup>
import { ref } from 'vue';
 
const isComponentAlive = ref(true);
 
// 强制销毁组件
const forceDestroy = () => {
  isComponentAlive.value = false;
};
</script>
posted @ 2025-03-19 18:24  起名字太难0123  阅读(8)  评论(0)    收藏  举报