[vue] vue-router重复路由跳转问题
原创
©著作权归作者所有:来自51CTO博客作者wx5909dcbadae4c的原创作品,请联系作者获取转载授权,否则将追究法律责任
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
// or
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
return originalReplace.call(this, location).catch(err => err)
}
or
this.$router.replace/push("xxx").catch(err => {err})
探究vue-router重复路由跳转问题