const sum = arr.reduce((sum, item) => { if (val === item.materialCode) { sum++; if (sum > 1) { arr[index] = { rowId: getRandomId(), processId: store.processId, projectId: props.productInfo.projectId }; return proxy.$modal.msgError('当前自制件已选择'); } } return sum; }, 0);

es6 将此代码优化 let sum = 0 forlet i = 0;iarrlength;i++ ifval === arrimaterialCode sum ++ ifNumbersum 1 arrindex = rowIdgetRandomIdproce

原文地址: http://www.cveoy.top/t/topic/iUzK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录