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)
}
}