vue-router报错:Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name的解决办法

更新:

vue已经修改此bug。

https://github.com/vuejs/vue-router/blob/dev/CHANGELOG.md

装一下依赖包吧。

 

以下为原文:

原文参考链接:https://blog.csdn.net/weixin_43202608/article/details/98884620

今天写项目遇到一个报错:Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}。反复检查后没有发现任何问题。

查了issues以后发现已经有人提了,并且已经修复此bug了。

有些bug,你一生只会遇到一次。

解决方法一:
node_modules文件夹删除, 重新npm i 以后,问题迎刃而解。

解决方法二:
不想删除node_modules可以只重新下载npm i [email protected] -S

 终极方法三(不建议):
 在main.js中捕获路由报错,写入如下代码:

import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

 

以上。

你可能感兴趣的:(VUE武功秘籍)