用push方法时的解决方案
在当前路由的文件夹中的js文件加入
//Push版本
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
用replace方法时的解决方案
同样也是在路由文件夹中js文件加入
//Replace版本
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
return originalReplace.call(this, location).catch(err => err);
}