最近在写项目的偶然发现了一个小bug,就是在本页面进行路由跳转的时候,如果跳转的还是本页面就会报错
在这里插入图片描述
这个时候就需要我们添加下面的代码就可以解决
1.先获取原型对象身上的跳转(push)方法
const originalPush = VueRouter.prototype.push
2.然后再进行一下修改
VueRouter.prototype.push = function push(location){
return originalPush.call(this, location).catch(err => err)
}

Logo

前往低代码交流专区

更多推荐