我正在将值从数组输出到表中,我想让某些值以不同的样式输出。我认为您可以通过 id 检查或添加另一个布尔属性来确定这些对象并向它们添加一个类,但我不知道如何编写它
export default class Table extends Component {
regions = [{
id: 1,
coal: 94100,
wood: 500,
oil: 1500,
},
{
id: 2,
coal: 4300,
wood: 500,
oil: "-",
},
];
render() {
return (
<div className="table-box">
<table className="curr-status-table">
<thead>
<tr>
<th>coal</th>
<th>wood</th>
<th>oil</th>
</tr>
</thead>
<tbody>
{this.regions.map((local) => (
<tr key={local.id}>
<td>{local.coal}</td>
<td>{local.wood}</td>
<td>{local.oil}</td>
</tr>
))}
</tbody>
</table>
</div>
);
}
}