component的is写法优化
<template>
<component :is='component'></component>
</template>
<script setup lang='ts'>
import { ref, shallowRef } from 'vue'
import A from './A.vue'
// 直接通过这种形式还是会有数据劫持,但是没有必要,因此会有警告
// const component = ref(A)
// 用通过shallowRef来解决数据劫持的问题
const component = shallowRef(A)
</script>
<style scoped lang='scss'>
</style>
浙公网安备 33010602011771号