React 多选框

Posted zhanglanzuopin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}

以上是关于React 多选框的主要内容,如果未能解决你的问题,请参考以下文章

Selenium—选择框的相关操作(单选框多选框复选框下拉框)

Layuilayui 单选框多选框radio 元素判断是必填项 lay-verify=‘required‘

Layuilayui 单选框多选框radio 元素判断是必填项 lay-verify=‘required‘

Layuilayui 单选框多选框radio 元素判断是必填项 lay-verify=‘required‘

ayui 单选框多选框radio 元素判断是必填项 lay-verify='required'

React 多选框