https://imgchr.com/i/MgGOYj
https://imgchr.com/i/MgGLkQ
我也是同样的问题, 网上找了下,说是vue-router升级了, push和replace回返回异常,需要catch。
升级了依赖包之后,我也遇到这个问题,等待大神解决
我也有这个问题 QAQ
处理方案
this.$router.push({
name: `${name}`
}, () => {})
const originalPush = VueRouter.prototype.push
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)
}
@Roc1010 谢谢兄弟,只是它既然replace为true,想必底层使用的是replace,你这里的push应该全都换成replace吧?我自己做了实验,全换成replace解决了问题,还是感谢你!!
@Roc1010 谢谢兄弟,只是它既然replace为true,想必底层使用的是replace,你这里的push应该全都换成replace吧?我自己做了实验,全换成replace解决了问题,还是感谢你!!
是的,这里只是拿push举例
你这里的push应该全都换成replace吧
@yzbas123 那就奇怪了, 虽然 next({ ...to, replace: true }) 是这样写,但是我 catch push 解决问题,catch replace 反而不行。
Most helpful comment
处理方案