有的时候会遇到这样的问题:路由跳转的时候报错
Uncaught (in promise) Error: Navigation aborted from "/my" to "/my/other" via a navigation guard.
解决方法
1.引入vue-router
在main.js 文件中
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
return originalPush.call(this, location).catch(err => { })
}
2. .catch
在路由跳转的时候加上 .catch((err) => {}
this.$router.push('/my').catch((err) => {})