Solve the same route error in Vue

Routing jump problem

insert image description here

Js processing version

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 processing version

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);
};

Guess you like

Origin blog.csdn.net/qq_34191778/article/details/126167072