首页 > 其他 > 详细

vue报错:Avoided redundant navigation to current location: "/"的解决方法

时间:2021-02-15 23:04:17      阅读:34      评论:0      收藏:0      [点我收藏+]

vue项目报错:Avoided redundant navigation to current location: "/"。先说一下是怎么触发这个报错的,就是博主用element ui写得侧边导航栏中用到了路由,然后重复点击这个路由就出现这个报错了。其实这个报错并不影响项目的正常运行,但是作为有一点代码洁癖的程序员,这种红色的错误信息是绝对无法忍受的!
技术分享图片
所以,百度之后得到下面最简单的解决方法:

打开你router目录下的index.js文件,复制下面代码,添加到最下方就可以了。

const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

问题完美解决。

vue报错:Avoided redundant navigation to current location: "/"的解决方法

原文:https://www.cnblogs.com/mambaforever/p/14403979.html

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