Vue-router错误:Error: Avoided redundant navigation to current location

错误提示

引入ElementUI后,重复点击一个具有路由跳转功能的按钮会出现如下提示:
NavigationDuplicated: Avoided redundant navigation to current location:xxx


图片.png

解决方案

在router文件夹下面的index.js 中加入如下代码:

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

代码图解:


图片.png

你可能感兴趣的:(Vue-router错误:Error: Avoided redundant navigation to current location)