vue3+vite 使用defineAsyncComponent动态异步引入组件出错时的解决办法

const name = 'c1'
const currentComponent = shallowRef()
const components = import.meta.glob("./a/*.vue");
currentComponent.value = defineAsyncComponent(components['./a/'+name+'.vue'])

<component v-bind:is="currentComponent"></component>

 

参考:https://cn.vitejs.dev/guide/features.html#glob-import

posted @ 2022-10-18 05:30  alpiny  阅读(1976)  评论(0编辑  收藏  举报