简化demo

This commit is contained in:
jonyshi 2018-06-25 13:02:22 +08:00
parent 20d9185ba8
commit 28acd42a2e
1 changed files with 4 additions and 8 deletions

View File

@ -81,8 +81,7 @@ class Demo1 extends Component {
super(props); super(props);
this.state = { this.state = {
data: data, data: data,
factoryValue: 0, selectedRowIndex: 0
selectedRow: new Array(data.length)//状态同步
} }
} }
@ -92,18 +91,15 @@ class Demo1 extends Component {
columns={columns} columns={columns}
data={data} data={data}
rowClassName={(record,index,indent)=>{ rowClassName={(record,index,indent)=>{
if (this.state.selectedRow[index]) { if (this.state.selectedRowIndex == index) {
return 'selected'; return 'selected';
} else { } else {
return ''; return '';
} }
}} }}
onRowClick={(record,index,indent)=>{ onRowClick={(record,index,indent)=>{
let selectedRow = new Array(this.state.data.length);
selectedRow[index] = true;
this.setState({ this.setState({
factoryValue: record, selectedRowIndex: index
selectedRow: selectedRow
}); });
}} }}
title={currentData => <div>标题: 这是一个标题</div>} title={currentData => <div>标题: 这是一个标题</div>}