render() { const columns = [ { title: '序号', width: 100, dataIndex: (index)=>`${(current-1)*pageSize+index+1}`, render:(text,record,index)=>`${(current-1)*pageSize+index+1}`, }, { title: "模板名称", dataIndex: "name", key: "name", width: 200, }, { title: "使用状态", dataIndex: "status", key: "status", width: 200, className:"useStatus", // onClick=this.showModal(record.id), render:(text,record)=>{ // 0停用,1启用 switch(text){ case 1: return '启用' default: return '停用' } // if(status == "0"){ // return "停用" // }else{ // return "启用" // } } }, { title: "操作", width: 200, render: (text, record) => { return ( <div className="table-row-button" onClick={e => e.stopPropagation()}> <span onClick={()=>this.setId(record.id)} className={Style.a_color}> 操作 </span> <Divider type="vertical" /> { record.status===1? <span onClick={()=>this.setVehicleApplyStatus(record.id,2,'在途中')} className={Style.a_color}> 启用 </span> :null } { record.status===0? <span onClick={()=>this.setVehicleApplyStatus(record.id,2,'在途中')} className={Style.a_color}> 停用 </span> :null } </div> ); } } ]; </Layout> );
1、在render里传参render(text,record);
render:(text,record)=>{
// 0停用,1启用
switch(text){
case 1:
return '启用'
default:
return '停用'
}
},
2、根据record对应传值显示自定义
{
record.status===1?
<span onClick={()=>this.setVehicleApplyStatus(record.id,2,'在途中')} className={Style.a_color}>
启用
</span>
:null
}