VueRouter Error: Avoided redundant navigation

Home / Article MrLee 2020-8-6 1751

错显示路由重复,对功能没有影响,可是强迫症看着不爽。

解决方法:在路由文件里添加这一句可解决报错问题

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

 router 文件下 index.js 中添加上面代码即可。

注意:Router还是VueRouter取决于你文件中的定义。


本文链接:https://www.it72.com/12655.htm

推荐阅读
最新回复 (0)
返回