ForEach exits the loop in JavaScript
In JavaScript, forEach loop, break and return are both unable to jump out of the loop, you need to use the method of throwing an exception to jump out of the loop
code show as below:
try {
BarCodeList.forEach(lst => {
if (lst.SNO == item.SNO) {
抛出异常,跳出循环
throw new Error("EndIterative");
}
});
} catch (e) {
if (e.message != "EndIterative") {
mui.alert("数据获取异常请重试!");
throw e;
}
}