在router文件夹下的路由文件中添加一下代码:
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push= function push(location) {
return originalPush.call(this, location).catch(err => err)
}
如果还是无法解决,则改成replace,再试一试:
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return originalReplace.call(this, location).catch(err => err)
}