有无了解react全选反选中checked是怎么传值的?求助~

click() {
var CheckAll = document.getElementById('All');
var CheckBox = document.getElementsByName('box');
if (CheckAll.checked == true)
for (var i = 0; i < this.props.items.length.length; i++) {
CheckBox[i].checked = false;
};
if (CheckAll.checked == false)
for (var i = 0; i < this.props.items.length.length; i++) {
CheckBox[i].checked = true;
};
for (var i = 0; i < this.props.items.length.length; i++) {
if (CheckBox[i].checked == true) {
CheckBox[i].checked = false;
}
else {
CheckBox[i].checked = true;
}
};
this.setState(
this.state.checked = checked 
);
}
render(){
let items = [];
if(this.props.items.length == 0) {
items.push(<tr><th colSpan="5" className="tempEmpty">暂无用户</th></tr>);
}else {
this.props.items.forEach(item => {
items.push(<StaffItem key={item.key} item={item} removeStaffItem={this.props.removeStaffItem} detailStaffItem={this.props.detailStaffItem}/>);
});
}

return (
<table className='itemPanel'>
<thead>
<th> <input type="checkbox" id='all' onChange={this.click.bind(this)} /> </th>
<th className='itemTd'>姓名</th>
<th className='itemTd'>年龄</th>
<th className='itemTd'>身份</th>
<th className='itemTd'>性别</th>
<th className='itemTd'>操作</th>
</thead>
<tbody>{<td className='itemTd'><input type="checkbox" classname='box' checked={this.state.checked} onChange={this.click.bind(this)}/></td>}</tbody>
</table>
);
}
}

SMILET
浏览 192回答 1
1回答

守着星空守着你

Failed to create directoryCCLOG("AssetsManagerEx : can not create directory %s\n", fullPath.c_str());unzClose(zipfile);return false;}}
打开App,查看更多内容
随时随地看视频慕课网APP