原因一:
try中的方法没有抛出异常
原因二:
try中抛出的异常类型不属于catch的异常类或者它的子类
原因三:
try中的方法是异步方法以致于下面catch不到,这种情况可以将异常获取移动到异步方法内部进行处理
try {
let res = await competiveUnderEvaluation({ eid: this.$route.query.eid })
if (res.success) {
this.netError1 = false
this.haedData = res.data
this.animationData = res.data
this.getScore = true
console.log(this.getScore, 'this.getScore')
this.handelAnimationData()
} else {
this.netError1 = true
if (res.code === -100) {
this.netText = '出故障了,请稍后重试'
}
}
} catch (e) {
// console.log(455555555);
this.netError1 = true
}
里面不能是axios.then的形式,那样会导致捕获不到异常