我按如下方式加载组件:
export default defineComponent({
components: {
ClickToEdit: () => import('@/components/form/ClickToEdit.vue'),
PlaceRankSettings: () => import('@/views/placerank/components/PlaceRankSettings.vue'),
LoadingPanel: () => import('@/components/form/LoadingPanel.vue'),
...
},
在模板中,我使用的设置如下:
<PlaceRankSettings
:loading="loading"
@select="updateViewMode"
/>
问题vite
在本地一切正常,但是当我使用
vite build
时,设置组件呈现为
<!---->
。我尝试将导入包装在
async/await
、
defineAsyncComponent
等中,但没有任何效果。此外,所有其他组件都已正确渲染。
关于为什么一个设置组件没有被渲染有什么想法吗?
https://github.com/NightCatSama/vue-slider-component/issues/642.
解决方案requireReturnsDefault: true
上添加
vite.config.js
:
export default defineConfig({
// ...{ otherOptions }
build: {
commonjsOptions: {
requireReturnsDefault: true,
},
},
})