hugh 的个人博客

Everyday is a new day

vue-router报NavigationDuplicated uncaught异常

1. 版本

3.1.0以上

2. 解决

vue-router issue里给出的解决方案

import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.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)
}

ts:

import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.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)
}

标题:vue-router报NavigationDuplicated uncaught异常
作者:hugh0524
地址:https://blog.uproject.cn/articles/2020/05/26/1590461309405.html