//router.(location, onComplete?, onAbort?)
this.$router.push({
name:'myRouter',
params:{
a:1
}
},(to)=>{
console.log(to'onComplete')
},(msg)=>{
console.log(msg,'onAbort')
})
-
onComplete
onComplete为成功跳转后调用,to为跳转到的路由信息如下图:
-
onAbort
onAbort在跳转路由终止 (导航到相同的路由、或在当前导航完成之前导航到另一个不同的路由) 的时候进行相应的调用,msg参数为跳转的过程描述信息,例如,在beforeRouteEnter中使用next(‘/otherPath’)将路由转换到第三个地址,就会触发onAbort,msg如下图
该信息描述了,从/跳转到/myRouter/1时被重新定向了(并没有说明定向到哪)
注意:当路由在同一个路径跳转时,也会触发onAbort