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

在这里插入图片描述

出错原因路由中添加了相同的路由

解决方法

src/router/index.js中重写push方法

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

你可能感兴趣的:(vue,vue)