【发布时间】:2021-06-21 11:22:29
【问题描述】:
我用我的数据自动创建一个表,我需要将两个值传递给函数onPred1Change(),我需要输入值和循环计数器k
我该怎么做?
<Table striped bordered hover>
<thead>
<tr>
<th>#</th>
<th>Prediction</th>
</tr>
</thead>
<tbody>
{Object.keys(this.state.jsondata.label).map(k =>
<tr>
<td>{k}</td>
<td>
<input
id={'pred' + k}
className="form-control"
type="text"
value={this.state.jsondata.prediction[k]}
onChange={e => this.onPred1Change(e.target.value)}
/>
</td>
</tr>
)}
</tbody>
</Table>
因为我需要k 来查找数据的索引,而value 来修改这些数据。
这是我使用k 的快速示例:
<Button variant="success" onClick={() => { this.validatePred2(k) }}>Validate <Check/></Button>
【问题讨论】: