运行代码出错,无法运行,错误在于插件vite:import-analysis

来源:1-1 课前须知,这里有你需要了解得一切

慕设计9348276

2021-05-27

let routes = utils.generateRoute(menuList)
routes.map(route => {
let url = ./../views/${route.component}.vue
route.component = () => import(url);
router.addRoute(“home”, route);
})
提示这段动态引入不能给vite解析,请问老师应该如何解决? 谢谢。

错误信息如下:

9:38:59 ├F10: AM┤ [vite] warning:
D:/daniel/manager-fe/src/router/index.js
55 | routes.map(route => {
56 | let url = ./../views/${route.component}.vue
57 | route.component = () => import(url);
| ^
58 | router.addRoute(“home”, route);
59 | })
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#l
imitations for supported dynamic import formats. If this is intended to be left
as-is, you can use the /
@vite-ignore / comment inside the import() call to su
ppress this warning.

Plugin: vite:import-analysis
File: D:/daniel/manager-fe/src/router/index.js

写回答

1回答

河畔一角

2021-05-31

你的let url为什么没有引号?

0
2
河畔一角
回复
慕设计9348276
换成这样试一下: (async function () { await loadAsyncRoutes(); })()
2021-06-04
共2条回复

Vue3+ElementPlus+Koa2 全栈开发后台系统

从前端晋级到全栈,让你的未来发展有更多可能

1069 学习 · 580 问题

查看课程