【问题标题】:vue3 async component with multi modules具有多模块的 vue3 异步组件
【发布时间】:2021-10-07 11:38:47
【问题描述】:

在我的项目中,我想将组件加载为异步组件。我发现我可以使用“defineAsyncComponent”,但它只是加载默认模块。是否可以加载其他模块?比如异步加载import {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.js vuejs3


    【解决方案1】:

    应该可以通过像这样将它声明为变量来加载你想要的任何组件,只要它是一个 Vue 组件:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-28
      • 2021-10-24
      • 1970-01-01
      • 2021-02-18
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      相关资源
      最近更新 更多