vue路由中 Navigating to current location ,"/router" is not allowed

报错原因:多次点击同一路由,导致路由被多次添加

解决方法:

router/index中添加以下代码:

//router/index.js
Vue.use(VueRouter) //导入vue路由
const VueRouterPush = VueRouter.prototype.push 
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

之后就不会再报路由错误了

参考自:https://www.jianshu.com/p/a140ad42ef00

以上。