在代码中使用forEach进行遍历,达到某一条件,希望跳出循环,代码不继续执行无法实现,可以用for循环代替:
isRepeat(arr){
let hash = {};
for(let i in arr) {
if(
hash[arr[i].param]
) {
return true;
} else {
hash[arr[i].param] = true;
}
}
return false;
},
或者使用以下方法:
isNull(arr){
let result = true;
if (Array.isArray(arr)) {
arr.forEach(item => {
if (item.param) {
if ((!item.defaultValue) && (!item.maxValue && !item.minValue)) {
result = false
}
}
});
}
return result;
},