如果是push
const originalReplace = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalReplace.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
如果是replace
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace= function replace(location) {
return originalReplace.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
..............