【Vue】解决vue-router报 NavigationDuplicated: Avoided redundant navigation to current location

image
它的提示是 避免到当前位置的冗余导航。就是重复触发了同一个路由。
报错显示路由重复,对功能没有影响。

解决方法

router 文件下添加下面代码即可

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

image

posted @ 2021-07-06 11:45  曾经的点工  阅读(1601)  评论(0编辑  收藏  举报