# router.push返回promise
# 问题截图:
# 问题描述
经排查问题出现在这两行代码
// functionName: jumpTo(id)
this.$router.push({name: this.menuData[index].idName})
->
// functionName: router.beforeEach((to,from,next) => )
next("/login")
代码逻辑是为了在跳转到其他页面之前,检查是否登录,没有登录就跳转到登录页面 问题就出现在this.$router.push({name: this.menuData[index].idName}),这句代码在高版本中 会返回一个Promise,但是在低版本中没有,因此转化到高版本之后也就没有去catch Promise,就导致了Ucaught runtime errors
# 提供的解决方案
- 对返回的Promise进行catch
this.$router.push({name: this.menuData[index].idName}).catch(err => {})
- 使用低版本的Vue