我在几个复选框组中运行了几个复选框。我无法弄清楚如何取消选中(从而改变状态)特定的复选框。由于某种原因,我无法访问e.target.checked。
<Checkbox
size="small"
name={item}
value={item}
checked={checkboxvalues.includes(item)}
onChange={(e) => handleOnChange(e)}
/>
和我的函数
const handleOnChange = (e) => {
const check = e.target.checked;
setChecked(!check);
};
我在这个sandbox中制作了一个可工作的组件示例。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号