Vue-router报错 redundant navigation to current location: “/roles”… 解决问题
在写Vue项目的时候遇到多次点击链接报错Error: Avoided redundant navigation to current location: “/roles”.如下图
想要解决这个问题首先找到router文件夹下面的index.js中加上下面几句代码,就OK了
// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
然后再去页面刷新,问题就解决了。