我尝试在 React 中制作一个自定义复选框。我能够做到,但一旦我检查了它,我将无法恢复它。我从 JSON 数据中检查和未检查的值。
组件代码
<td>
<div class="custom-control custom-checkbox">
<input
type="checkbox"
checked={venue.block}
class="custom-control-
input"
id={'block-venue-' + venue.id}
name={'block-venue-' + venue.id}
/>
<label class="custom-control-label" for={'block-venue-' + venue.id}></label>
</div>
</td>
JSON 对象示例
[
{
"id":"one",
"photo":"/img/venue.jpg",
"name":"One",
"address":"saket, new delhi",
"manager":"pranay kumar",
"email":"pranay.kumar@hello.com",
"phone":"00900090",
"block":true
},
]