Elment-admin时动态权限加载出现跳转页面空白 component问题
发布于 3 年前 作者 huaer 1478 次浏览 来自 问答
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利

如题,首先我参照的是https://blog.csdn.net/Hero_rong/article/details/103367776
该文章的代码步骤,最后路由都从后台拿到了,也能点,但是点了发现跳转页面是空白的
我感觉是component的问题!这是我从后台拿的然后转了一下

我和默认的sgyncRoutersbi比对了一下,是一样的

代码如下

export function menu(value) {
  const data = value
  data.forEach((item) => {
    item.redirect = item.path
    item.hidden = false
    item.alwaysShow =true
    item.component = () => import('@/layout')
    const childs=item.children
    for(const i in childs){

      childs[i].path = item.path + childs[i].path
      let str = childs[i].path
      childs[i].component= ()=>import('../views'+ str +'.vue')
      childs[i].hidden = false
    }
  })
  return data

}

我也看了admin-element文档https://panjiachen.github.io/vue-element-admin-site/zh/guide/essentials/permission.html#%E9%80%BB%E8%BE%91%E4%BF%AE%E6%94%B9

是这样说的:

只是多了一步将后端返回路由表和本地的组件映射到一起。相关issue

const map={
 login:require('login/index').default // 同步的方式
 login:()=>import('login/index')      // 异步的方式
}
//你存在服务端的map类似于
const serviceMap=[
 { path: '/login', component: 'login', hidden: true }
]
//之后遍历这个map,动态生成asyncRoutes
并将 component 替换为 map[component]
Ps:不排除之后本项目会增加权限控制面板支持真正的动态配置权限。

#逻辑修改

请问下大佬,怎么搞定

回到顶部