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

以上。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM