NavigationDuplicated: Avoided redundant navigation to current location: "/xxx".的解决方法

最近在Vue项目开发的过程中遇到一个问题,那就是在点击同一个路由操作的时候,控制台会报错误提示。

它的提示是避免到当前位置的冗余导航。

简单来说就是重复触发了同一个路由。

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

posted @ 2022-07-02 20:39  槑孒  阅读(1569)  评论(0编辑  收藏  举报