Vue 路由报错 NavigationDuplicated: Navigating to current location is not allowed 解决方法

使用 Vue 2.x 开发项目,路由当然也是用的官方的路由,一直也是挺好用的,但是如果是相同的页面,也就是重复点击就会报错:

Vue 路由报错 NavigationDuplicated: Navigating to current location is not allowed 解决方法

vue.esm.js?efeb:628 [Vue warn]: Error in v-on handler (Promise/async): “NavigationDuplicated: Navigating to current location (“/register?type=lawyer”) is not allowed”

这种情况改写一下路由的 push 方法就可以了,将要跳转的 location 的路由放进去。

const routerPush = Router.prototype.push

Router.prototype.push = function push(location) {

return routerPush.call(this, location).catch(error=> error)

}

Vue 路由报错 NavigationDuplicated: Navigating to current location is not allowed 解决方法

以上是 Vue 路由报错 NavigationDuplicated: Navigating to current location is not allowed 解决方法 的全部内容, 来源链接: utcz.com/p/232515.html

回到顶部