Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue 添加动态路由懒加载组件报错 Error: Cannot find module - 简书 #214

Open
xiaodongxier opened this issue Oct 10, 2023 · 0 comments

Comments

@xiaodongxier
Copy link
Owner

今天初始化想项目的时候需要添加动态路由,本以为是一个简单需求,结果进了一个大坑!

import 组件的时候直接写静态地址是可以,换成变量就不可以:

原因应该是在webpack,webpack 编译es6 动态引入 import() 时不能传入变量,因为webpack的现在的实现方式不能实现完全动态。

需要在变量前边加一个字符串 @/views ;注意@后边一定要跟一级目录

如果还是不行的话改成resolve引入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant