解决ElementUI导 航栏中的vue- router在3 .0版本以 上重复点菜单报错问题

前言:在使用ElementUI中的导航时,默认情况下如果重复点击某选项,会报错,虽然对项目没啥影响,但红色报错真的很难受。

诺!
解决ElementUI导 航栏中的vue- router在3 .0版本以 上重复点菜单报错问题_第1张图片
可以在router的配置文件中(router -> index.js)加上下面这句话,

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

注意位置:
解决ElementUI导 航栏中的vue- router在3 .0版本以 上重复点菜单报错问题_第2张图片

你可能感兴趣的:(vue,visual,studio,code,经验分享)