React 多选框
if(record.name == this.state.deleteCheckbox[0].name){ console.log(record.name,this.state.deleteCheckbox[0].name,"多选框 和 点击按钮都一样 传哪个值都可以") }else{ message.error("请点击当前行按钮") console.log(record.name,this.state.deleteCheckbox[0].name,"请点击当前行按钮") return; } --------------------------------------------------------------------------------------------- if(this.state.location.dataCenter == "全部数据中心"){ this.state.location.dataCenter = 0 }else if(this.state.location.dataCenter == "主数据中心-内网区"){ this.state.location.dataCenter = 1 }else if(this.state.location.dataCenter == "主数据中心-外网区"){ this.state.location.dataCenter = 2 }else{ this.state.location.dataCenter = 3 } if (this.state.deleteCheckbox.length == 1) { } else if (this.state.deleteCheckbox.length == 0) { message.error("请选择一条数据"); } else if (this.state.deleteCheckbox.length > 1) { message.error("只能选择一条数据"); } if (this.state.deleteCheckbox.length == 1) { // window.location.href = "#/cloudResource/virtualMachine/SyszLookDetail" this.state.deleteCheckbox.map((item, index) => { // var storage = window.sessionStorage; // storage.setItem("vmDetail", JSON.stringify(item)) this.props.router.push({ pathname : 'cloudResource/virtualMachine/SyszLookDetail' ,state : { name: item} }) console.log(item,"我是虚拟机 查看详情") }) } else if (this.state.deleteCheckbox.length == 0) { message.error("请选择一条数据") } else if (this.state.deleteCheckbox.length > 1) { message.error("只能选择一条数据") } --------------------------------------------------------------------------------------------- render: (text, record) => { return <Checkbox onChange={(e) => this.handleCheckbox(e.target.checked, 'AUTHORITY_ALL', text,record)} // checked={record.AUTHORITY_ALL} checkd = {true} value={record.ID} // indeterminate = {true} // defaultChecked = {true} autoFocus = {true} /> }, --------------------------------------------------------------------------------------------- { title: '', key: 'AUTHORITY_ALL', dataIndex: 'AUTHORITY_ALL', // render: (text, record) => (<Checkbox onChange={this.handleCheckbox} checked={record.AUTHORITY_ALL} value={record.ID} />), render: (text, record) => (<Checkbox onChange={(e) => this.handleCheckbox(e.target.checked, 'AUTHORITY_ALL', text,record)} checked={record.AUTHORITY_ALL} value={record.ID} />), }, handleCheckbox=(e,type,id,text,record) => { console.log(e, type, id,text,record); }