vue3异步组件与多模块



在我的项目中,我想将组件加载为异步组件。我发现我可以使用defineAsyncComponent",但它只是加载默认模块。是否可以加载其他模块?例如async loadimport {ArrowLeftOutlined, UploadOutlined} from '@ant-design/icons-vue'?

const asyncBbox = defineAsyncComponent({
loader: () => new Promise((resolve) => {
if (componentName)
resolve(import('./example-label-component'));
resolve({
template: '<div>Undefined Component</div>'
})
}),
timeout: 3000
});

只要是Vue组件,就可以通过这样的变量来加载任何组件:

const myCustomComponent = defineAsyncComponent(() => import('@/ant-design/icons/ArrowLeftOutlined.vue'))

最新更新