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

出现的错误:在这里插入图片描述
出现这个错误的原因是,在路由跳转的时候两次push的path地址相同

解决方法两种:

1.切换版本回3.0版本

2.在你引了vue-router的js文件里加上如下代码即可

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章