-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
从数据库查到数据后, 动态加载路由, 报Cannot find module #1141
Comments
@moxuanluo 问题解决了么, |
请问下载这个问题解决了吗 |
我同样遇到这个问题,久思未果,如果问题有结果请麻烦告知 |
同遇到这个问题。。直接写就没问题 |
完美解决。 export const loadView = (view) => { // 路由懒加载 |
大神您好,我 从后台数据库查寻数据生成路由表,菜单列表,权限都能出来,但是在路由异步加载的时报Cannot find module '@/views/layout/layout'
希望大神您能帮我看一下问题出在了哪里
我是将路径@/views/layout/layout 用varchar格式存入mysql 数据库 将数据查询到页面后,
我创建了变量来接受路由信息
let newRouter =[
{ path: data.path,
component: () => import(data.component),
name:data.name
}
]
变量创建完毕后,执行了
accessedRouters = filterAsyncRouter(nr, roles)
commit('SET_ROUTERS', accessedRouters)
成功生成addRouters
页面 可以 成功显示出 对应的菜单, 但是 点击菜单进行路由时,就会报Cannot find module ‘@/views/layout/layout ’ 这个错误,
我把上面的 newRouter 变量的 component 直接写成 () => import(‘@/views/layout/layout ’ ) 是不会报任何的错误,
想问一下 大神 () => import(data.component) 如何才能成功路由
The text was updated successfully, but these errors were encountered: