一、错误描述 : 当点击的菜单,就对应当前路由时,出现以下错误
vue-router.esm.js?8c4f:2007 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
二、方法一:重新安装 vue-router ![](https://img-blog.csdnimg.cn/2019120310272078.png)
npm i vue-router@3.0 --save
三、方法二: 已经重新安装了,还是不行
那就在文件 main.js 中添加以下代码, 其实就是抛出异常
import Router from 'vue-router'
// 点击当前路由的菜单,抛出异常`NavigationDuplicated`
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error=>error)
}
写给自己的随笔,有问题欢迎指出ψ(*`ー´)ψ