直接上代码(使用try catch来实现终止循环)
try {
this.dataList.forEach((item) => {
console.log('answerResult', item.answerResult == undefined);
if (item.answerResult == undefined) {
this.modelShow = true
throw new Error("breakForEach");//停止循环
}
})
} catch (e) {
return; //结束代码 后面代码不再执行
}