美文网首页
[vue-router] Duplicate named rou

[vue-router] Duplicate named rou

作者: Linseed | 来源:发表于2020-08-27 14:13 被阅读0次

翻译:vue-router 重复的命名路由定义
静态路由:只需要修改重复 name
动态路由:没有添加过才添加

router.$addRoutes = (params) => {
  router.matcher = new Router({ mode: 'history' }).matcher
  router.addRoutes(params)
}
router.beforeEach((to, from, next) => {
    //没有添加过才添加
    if (router.options.routes[0].children.length < 10) {
        router.options.routes[0].children = router.options.routes[0].children.concat(dynamicRoutes)
        router.$addRoutes(router.options.routes)
      }
})

相关文章

网友评论

      本文标题:[vue-router] Duplicate named rou

      本文链接:https://www.haomeiwen.com/subject/cvucsktx.html