路由跳转问题
Js处理版本
import VueRouter from 'vue-router';
const oldPush = VueRouter.prototype.push;
const oldReplace = VueRouter.prototype.replace;
VueRouter.prototype.push = function (location) {
return oldPush.call(this, location).catch(err => err);
};
VueRouter.prototype.replace = function (location) {
return oldReplace.call(this, location).catch(err => err);
};
Ts处理版本
import VueRouter, { RawLocation, Route } from 'vue-router';
const oldPush: (location: RawLocation) => Promise<Route> = VueRouter.prototype.push;
const oldReplace: (location: RawLocation) => Promise<Route> = VueRouter.prototype.replace;
VueRouter.prototype.push = function (location: RawLocation) {
return oldPush.call(this, location).catch((err: any) => err);
};
VueRouter.prototype.replace = function (location: RawLocation) {
return oldReplace.call(this, location).catch((err: any) => err);
};