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

报错缘由:屡次点击同一路由,致使路由被屡次添加
解决方法:vue

router/index中添加如下代码:this

//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)
}

以后就不会再报路由错误了prototype

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

以上。router

相关文章
相关标签/搜索