![【React】遍历的两种方式 【React】遍历的两种方式](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
1、foreach(推荐)
list.forEach((item)=>{
});
eg:
dataSource.forEach((item) => {
const est = item.estimateAmount === null ? 0 : parseFloat(item.estimateAmount);
const gmv = item.estimateGmv === null ? 0 : parseFloat(item.estimateGmv);
allCountBudget += est;
allCountGmv += gmv;
// allCountGmv = parseFloat(allCountGmv) + parseFloat(gmv);
});
2、map(内部不支持计算逻辑?)
list.map((item, index)=>
<div>
{item.name}
</div>
)
)