vue路由重复报错
今天遇到个小问题,我在前端页面检查时,跳转路由出现问题,报如下错误,即使目前不影响使用,但是后面可能会出错误。所以就找解决方法。
这种情况是点击了同一个导航而出现的问题,即路由重复。
在vue的代码index.js下。添加如下代码:
const router = new VueRouter({
routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
问题解决。