Vue路由重复跳转怎么解决(当前页面跳转当前路由会报错)
最近在写项目的偶然发现了一个小bug,就是在本页面进行路由跳转的时候,如果跳转的还是本页面就会报错这个时候就需要我们添加下面的代码就可以解决1.先获取原型对象身上的跳转(push)方法const originalPush = VueRouter.prototype.push2.然后再进行一下修改VueRouter.prototype.push = function push(location){r
·
最近在写项目的偶然发现了一个小bug,就是在本页面进行路由跳转的时候,如果跳转的还是本页面就会报错
这个时候就需要我们添加下面的代码就可以解决
1.先获取原型对象身上的跳转(push)方法
const originalPush = VueRouter.prototype.push
2.然后再进行一下修改
VueRouter.prototype.push = function push(location){
return originalPush.call(this, location).catch(err => err)
}
更多推荐
已为社区贡献1条内容
所有评论(0)