vue报错Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location...

今天学习vue-router时出现如下报错,百度了一下,好像是vue-router版本不兼容的问题,解决方法为在router/index.js文件中加入一段代码

报错提示信息
vue报错Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location..._第1张图片

报错代码
vue报错Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location..._第2张图片

需要插入的代码段

const originalPush = VueRouter.prototype.push

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

代码插入位置
vue报错Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location..._第3张图片

参考文章
https://blog.csdn.net/luer_LJS/article/details/108362563

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