我想在我的表格中添加一個<input>
元素,更具體地說是一個複選框。以下作品:<input>不能作爲孩子出現<tr>
<tbody key={rule._id}>
<tr>
<td>{rule.deviceId}</td>
{
<input
name="isEnabled"
type="checkbox"
checked={rule.enabled}
/>
}
<td>{rule.name}</td>
</tr>
</tbody>
,但它產生在控制檯中的錯誤:<input> cannot appear as a child of <tr>
是否有一個「正確」的方式做到這一點?
啊,把它裏面 –
我想你錯過了一個''對。你需要將你的'input'包裝成一個 – Fotis
請參閱[here](https://stackoverflow.com/questions/5967564/form-inside-a-table) – Arkej