【发布时间】:2020-07-25 22:13:21
【问题描述】:
tableRenderer() {
let table = <Table striped bordered hover responsive="sm" id='mytable'>
<thead>
<tr>
{this.state.headers.map((header, index) =>
<th key={index}>{header} </th>
)}
</tr>
</thead>
{this.state.timeLabels.map((label, index)=>
<tr key={index}> <td><b>{label} </b></td>
{this.state.table.slice(0,4).map((match, index)=>
<td key={index}>{match.teamA} vs {match.teamB}</td>
)}
</tr> )}
</Table>;
但是我被困在我需要的最后一个功能上:如何更改表格数组切片的值,所以在第一次运行时它切片 0-> 音高数,第二次运行音高数-> 音高数+音高数...等。 我是否需要创建一些函数来在每次创建行时迭代一个变量?
【问题讨论】: