我正在尝试动态导入组件在我的应用程序,我在做什么:
const app = new Vue({
vuetify,
el: '#app',
components: {
'MainComponent': () => import(
/* webpackChunkName: "components/js/MainPage/MainComponent" */
'./components/MainPage/MainComponent.vue'
),
'OnlineReservationComponent': () => import(
/* webpackChunkName: "components/js/MainPage/OnlineReservationComponent" */
'./components/MainPage/OnlineReservationComponent.vue'
),
}
});
当我加载页面时,如果我得到一个错误,文件没有找到,
GET https://domain.test/components/js/MainPage/MainComponent.js net::ERR_ABORTED 404 (Not Found)
这是因为文件必须在核心文件夹
中文件夹结构
core
--public
---components
----js
-----mainPage
有没有办法让webpack像这样查看Core文件夹
https://domain.test/core/public/components/js/MainPage/MainComponent.js
在webpack.mix.js中写入
mix.webpackConfig({
output: {
publicPath: '/core/public/'
}
})
修复了我的问题