首页 > 其他 > 详细

vue-routerV3.1版本报错:message: "Navigating to current location ("/home") is not allowed",

时间:2019-11-07 19:41:30      阅读:3529      评论:0      收藏:0      [点我收藏+]

出现这个错误的原因是,在路由跳转的时候两次push的path地址相同

解决方法两种:

1.切换版本回3.0版本

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

import VueRouter from "vue-router";
// 解决两次访问相同路由地址报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

 

 

vue-routerV3.1版本报错:message: "Navigating to current location ("/home") is not allowed",

原文:https://www.cnblogs.com/bobo1/p/11814938.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!