<template>
<div>
<button @click="currentComponent = ComponentA">Load Component A</button>
<button @click="currentComponent = ComponentB">Load Component B</button>
<component :is="currentComponent"></component>
</div>
</template>
<script setup>
import ComponentA from '../components/ComponentA.vue';
import ComponentB from '../components/ComponentB.vue';
import { shallowRef } from 'vue'
let currentComponent = shallowRef(ComponentA)
</script>
vue3动态组件
最新推荐文章于 2024-04-30 11:19:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)