vue-router 报错、:Avoided redundant navigation to current location 错误、路由重复

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/goodsList".

在用vue-router 做单页应用的时候重复点击一个跳转的路由会出现报错

image.png

这个报错是重复路由引起的
只需在注册路由组建后使用下方重写路由就可以

import Router from 'vue-router';
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
image.png
image.png

你可能感兴趣的:(vue-router 报错、:Avoided redundant navigation to current location 错误、路由重复)