其他分享
首页 > 其他分享> > NavigationDuplicated错误显示

NavigationDuplicated错误显示

作者:互联网

Vue3.1版本出现中此异常,在路由器中添加如下代码

//先把原来的push方法保存起来
const originPush = VueRouter.prototype.push
const originReplace = VueRouter.prototype.replace
//把原来的push修改为另外一个方法
VueRouter.prototype.push = function(location,resolved,rejected){
  if(resolved === undefined && rejected === undefined){
    return originPush.call(this,location).catch(() => {})
  }else{
    return originPush.call(this,location,resolved,rejected)
  }
}

VueRouter.prototype.replace = function(location,resolved,rejected){
  if(resolved === undefined && rejected === undefined){
    return originReplace.call(this,location).catch(() => {})
  }else{
    return originReplace.call(this,location,resolved,rejected)
  }
}

标签:resolved,显示,错误,rejected,NavigationDuplicated,call,location,VueRouter,prototype
来源: https://www.cnblogs.com/Listener-wy/p/15037958.html