arrays - 如何在reactjs中选择多个复选框?
问题描述
问题是我需要传递对象数组,我无法获得我接受的数据。我接受的数据将是这种格式。但是,用户可以使用 unchecked 来删除。
{
notification : {group:["can_view","can_create", "can_delete","can_update","can_upload","can_download"],
topGroup:["can_view","can_create", "can_delete","can_update","can_upload","can_download"}
}
handleAllChecked = (id, role, data) => event => {
let fruites = this.state.fruites;
fruites
.filter(f => f.groupId === id)
.forEach(fruite => {
if (event.target.checked === true) {
fruite.isChecked = event.target.checked;
console.log(data);
} else {
fruite.isChecked = false;
}
});
this.setState({ fruites: fruites });
};
这是我的codesanbox,你可以很容易理解 https://codesandbox.io/s/fragrant-http-v35lf
解决方案
推荐阅读
- python - 熊猫 - GroupBy 2 列 - 无法重置索引
- rx-java - MissingBackpressureException:由于缺少请求而无法发出缓冲区
- sql - 如何在 SQL Server 中使用 SELECT 语句同时更改 where 子句和追加?
- go - 将 yaml 文件注入 Argo 工作流程步骤的最佳方法是什么?
- wordpress - 古腾堡侧边栏中的 DateTimePicker
- regex - Google 表格双精度值的条件格式规则
- python - 在 broswerstack 上运行 python 代码的问题
- javascript - 用正则表达式求解方程
- string - 有没有办法找到一个字符串的算法来生成更多相同算法的字符串?
- windows - 如何从 PowerShell 打开 url