使用Vue-cli3.x开发环境中(router采用 history模式)出现Failed to resolve async component default: Error: Loading chunk {n} failed.或者Uncaught SyntaxError: Unexpected token < 的错误
vue路由配置如下:
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '*', component: NotFoundComponent }
]
})
解决方案:
修改webpack的配置,
在vue.config.js文件中修改publicPath为 ‘/’ 即解决问题
module.exports = {
publicPath: '/', // <----这里就是会修改webpack的outPath.publicPath
}