报错信息:
Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
报错原因:
通过他人博客得知报错原因是因为使用的的vue-router版本是3.1.0,而vue-router在3.1.0 版本的路由跳转使用的是 promise 的方式,可能是因为vue的官方人员没设计好而造成了BUG,vue-router 官方 在 2019-08-06 推出的 [email protected] 已经修复了此bug。
解决方法:
1.安装3.1.1以上的vue-router版本可解决报错。
2.在router文件下的main.js添加一下代码
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
参考来源:https://blog.csdn.net/weixin_43202608/article/details/98884620