Skip to content
文章目录

vue-router中push方法重写

ts
import VueRouter, { RouteConfig, RawLocation, Route } from 'vue-router'
const originalPush = VueRouter.prototype.push as unknown as Promise<Route>
VueRouter.prototype.push = function push(location: RawLocation) {
  return (originalPush as any).call(this, location).catch((err: Error) => err)
}