// 解决编程式跳转路由报错的方法,在路由router下面的index.js文件里面写入。
// 将VueRouter原型中push 拿出来
let oldRouter = VueRouter.prototype.push;
//重新给路由实例上添加一个新的push方法
VueRouter.prototype.push = function push(loaction){
// console.log(location) //这个参数就是需要给路由重新定义的路径
// 改变旧的push方法this指向并从新指定路由跳转地址,使用catch对错误进行捕获
return oldRouter.call(this,location).catch(err=>err)
}
//搞定