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

NavigationDuplicated: Avoided redundant navigation to current location:_项目开发

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

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

const originalPush = VueRouter.prototype.push;

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

NavigationDuplicated: Avoided redundant navigation to current location:_项目开发_02

箴言:因为这些东西是非常简单的。不要抱怨自己学不会,那是因为你没有足够用心。