解决vue-router出现message: "Navigating to current location ("/admin/index") is not allowed"的问题
其原因在于Vue-router在3.1之后把$router.push()方法改为了Promise。所以假如没有回调函数,错误信息就会交给全局的路由错误处理,因此就会报上述的错误。 vue-router先报了一个Uncaught (in promise)的错误(因为push没加回调),然后再点击路由的时候才会触发NavigationDuplicated的错误(路由出现的错误,全局错误处理打印了出来)。 解决方案: 方案一(简单粗暴): 固定vue-router版本到3.0.7以下。这个方案没什么说的,就是简单粗暴,没有任何理由。 修改 vue-router 的 push 方法。 方案二(推荐): 找到路由文件,在 import Router from 'vue-router' 下面后添加如下代码: /** * 修改 vue-router 的push方法 */ const originalPush = Router . prototype . push ; Router . prototype . push = function push ( location , onResolve , onReject ) { if ( onResolve || onReject ) { return originalPush . call ( this , location , onResolve