错误信息
Cannot find module '@/views/login/index'
Failed to resolve async component default
vue-router.esm.js:1897 Error: Cannot find module '@/views/login/index'
at webpackEmptyContext (index.js:39)
at permission.js:90
1
2
3
4
5
解决方法
进入router中的index.js
component: () => import('@/views/login/index'),
1
改为
component: (resolve) => require(["@/views/login/index"], resolve),
1
如果是动态路由则
export const loadView = (view) => { // 路由懒加载
return () => import(`@/views/${view}`)
}
1
2
3
改为
export const loadView = (view) => { // 路由懒加载
return (resolve) => require([`@/views/${view}`], resolve)
}
1
2
3
错误原因是老外修改了webpack打包逻辑,webpack4中动态import不支持变量方式,
该修改对于生产环境无影响,只在开发环境有问题
如果解决了你的问题,请回来点赞哦。
————————————————
版权声明:本文为CSDN博主「mekave」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mekave/java/article/details/105954542