其他分享
首页 > 其他分享> > 前端开发:Vue项目报错NavigationDuplicated:Avoided redundant navigation to current location:“/XXX”的解决方法

前端开发:Vue项目报错NavigationDuplicated:Avoided redundant navigation to current location:“/XXX”的解决方法

作者:互联网

最近在Vue项目开发的过程中遇到一个问题,那就是在点击同一个路由操作的时候,控制台会报一下错误提示:

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/Refund".

经过排查之后才发现是关于Vue中路由重复引起的错误,经过查找资料以及搜索相关知识,该报错原因是因为ElementUI导航栏里面的vue-router在3.0以上版本重复点击菜单引起的路由重复报错,得出了以下解决步骤:

打开Vue项目,找到router文件夹下的index.js文件,

然后添加如下几行代码,即可解决问题,具体代码如下所示:

const includPush = Router.prototype.push

Router.prototype.push = function push(location) {

  return includPush.call(this, location).catch(err => err)

}

 

 

以上就是本章全部内容,欢迎关注三掌柜的微信公众号“程序猿by三掌柜”,三掌柜的新浪微博“三掌柜666”,欢迎关注!

三掌柜的微信公众号:

三掌柜的新浪微博:

 

标签:Vue,XXX,掌柜的,NavigationDuplicated,报错,location,push
来源: https://blog.csdn.net/CC1991_/article/details/112791714