Vue 项目路由出现 message: “Navigating to current location (XXX) is not allowed“的问题

message: "Navigating to current location (XXX) is not allowed"

原因:

在路由中添加了相同的路由

解决:

重写路由的push方法

src/router/index.js 里面 import Router from 'vue-router' 下面加上以下代码

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

 

 

 

 

 

https://blog.csdn.net/weixin_43606809/article/details/103040805

你可能感兴趣的:(Vue,Web,FrontEnd,Navigating,to,Navigating,is,not,allowed,Vue,路由)