使用无状态功能来反应添加组件

时间:2018-09-26 06:32:11

标签: reactjs

如何仅使用无状态功能组件来使按钮向k添加新的$result = []; $months = []; foreach($array as $items) { foreach($items as $item) { $months[$item['SalesMonth']] = $item['SalesMonth']; $result[$item['name']][$item['SalesMonth']] = ($result[$item['name']][$item['SalesMonth']]??0) + $item['TotalSales']; } } ?> <table> <tr> <th>Product</th> <?php foreach($months as $month):?> <th><?=$month;?></th> <?php endforeach;?> </tr> <?php foreach($result as $name => $items):?> <tr> <td><?=$name;?></td> <?php foreach($months as $month):?> <td><?=$items[$month]??0;?></td> <?php endforeach;?> </tr> <?php endforeach;?> </table> 组件?

<Card>

0 个答案:

没有答案