Arrays 如何在reactjs中选择多个复选框?
问题是我需要传递对象数组,我无法获取我接受的数据。我接受的数据将是这种格式。但是,用户可以使用“未选中”来删除Arrays 如何在reactjs中选择多个复选框?,arrays,reactjs,object,checkbox,Arrays,Reactjs,Object,Checkbox,问题是我需要传递对象数组,我无法获取我接受的数据。我接受的数据将是这种格式。但是,用户可以使用“未选中”来删除 { 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
{
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 });
};
这是我的密码箱,你很容易理解
请更详细地解释需要什么输出如果您想选择复选框“group”或“top group”,并相应地选择其子复选框,我猜您的代码更改const{listofdata}=this.state中有一个输入错误;常量newList=[…listofdata];to const{fruites}=this.state;const newList=[…水果];你能换一下吗。我遇到了一个错误,请更具描述性。例如,当用户单击组时,数据格式将为以下格式{group:[“can_view”,“can_create”]},当用户单击顶部组时{group:[“can_view”,“can_create],topgroup:[“can_view”,“can_create”]}