(js)循环判断找到满足条件的单项后结束循环
forEach结束循环正确用法:运用抛出异常(try catch)
if (newVal != "") {
try {
this.gxList.forEach((ele) => {
if (this.processId === ele.id) {
this.gxDisabled = false;//自己的逻辑
throw "StopIteration";
} else {
this.gxDisabled = true;//自己的逻辑
}
});
} catch (e) {
if (e !== "StopIteration") throw e;
}
}
1.中断forEach:https://blog.csdn.net/lwf3115841/article/details/131103069
2.https://blog.csdn.net/qq_37899792/article/details/97117010