【发布时间】:2021-08-22 10:13:16
【问题描述】:
我正在尝试异步加载组件。它在生产构建中运行良好,但在开发中失败。 我使用热模块替换进行开发,但在控制台上出现组件无法加载的错误。
这是我注册组件的方式:
Vue.component('product-page', ()=> import('./app/components/ProductPage.vue'));
错误:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Failed to resolve async component: function () {
return Promise.all(/*! import() */[__webpack_require__.e(0), __webpack_require__.e(1), __webpack_require__.e(2), __webpack_require__.e(32)]).then(__webpack_require__.bind(null, /*! ././app/components/ProductPage.vue */ "./src/app/components/ProductPage.vue"));
}
在我的 webpack 配置中,我有:
output:{
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js' ,
publicPath: 'http://localhost:8088/',
}
我需要什么特殊配置还是我做错了什么?
【问题讨论】:
标签: javascript vue.js webpack