Vue中路由报错:NavigationDuplicated: Avoided redundant navigation to current location: "/xxx".

开发环境能够正常启动

image.png

连续点击相同路由导致报错(不影响正常操作行为)

Vue中报错:NavigationDuplicated: Avoided redundant navigation to current location: "/xxx".

image.png

解决方法

在router的index.js中增加如下代码:

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

成功消除报错!

你可能感兴趣的:(Vue中路由报错:NavigationDuplicated: Avoided redundant navigation to current location: "/xxx".)