vue3动态组件
【代码】vue3动态组件。
·
<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>
更多推荐
已为社区贡献1条内容
所有评论(0)