为什么要重写,因为编程式路由导航多次路由跳转,会出现警告性的错误。
方法是在路由index.vue文件中重写路由push
let originPush = VueRouter.prototype.push
VueRouter.prototype.push = function(location, resolve, reject){
if(resolve && reject){
originPush.call(this,location, resolve,reject)
}else{
originPush.call(this,location,()=>{},()=>{})
}
}