Vue运行错误: Duplicate keys detected: '/'. This may cause an update error.

配置路由权限的时候遇到 vue 一个问题,这里记录一下。
检测到重复键,导致更新失败
主要原因是因为:key=‘data.path’,这里的 data 有问题,
下面的path都用了‘/’ 所以导致跟新失败
data 的值如下

export const constantRoutes = [{
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/homePage'),
      meta: {
        title: '主页',
        icon: 'homePage',
        affix: true
      }
    }]
  }

]

export const asyncRoutes = [{
    path: '/',
    name: 'UserManage',
    component: Layout,
    meta: {
      title: 'UserManage',
      icon: 'lock',
      roles: ['admin'] 
    },
    children: [{
      path: '/UserManage',
      name: 'UserManage',
      component: () =>
        import('../views/user/UserManage.vue'),
      meta: {
        title: '用户管理',
        icon: 'lock',
        roles: ['editor'] 
      }
    }]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值