|
|
@ -8,7 +8,6 @@ |
|
|
|
|
|
|
|
````jsx |
|
|
|
import { Transfer, Button } from 'antd'; |
|
|
|
const container = document.getElementById('components-transfer-demo-basic'); |
|
|
|
|
|
|
|
const App = React.createClass({ |
|
|
|
getInitialState() { |
|
|
@ -17,11 +16,9 @@ const App = React.createClass({ |
|
|
|
targetKeys: [], |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
this.getMock(); |
|
|
|
}, |
|
|
|
|
|
|
|
getMock() { |
|
|
|
let targetKeys = []; |
|
|
|
let mockData = []; |
|
|
@ -37,33 +34,25 @@ const App = React.createClass({ |
|
|
|
} |
|
|
|
mockData.push(data); |
|
|
|
} |
|
|
|
this.setState({ |
|
|
|
mockData: mockData, |
|
|
|
targetKeys: targetKeys, |
|
|
|
}); |
|
|
|
this.setState({ mockData, targetKeys }); |
|
|
|
}, |
|
|
|
|
|
|
|
handleChange(targetKeys) { |
|
|
|
this.setState({ |
|
|
|
targetKeys: targetKeys, |
|
|
|
}); |
|
|
|
this.setState({ targetKeys }); |
|
|
|
}, |
|
|
|
|
|
|
|
renderFooter() { |
|
|
|
return <Button type="primary" size="small" style={{ float: 'right', margin: '5' }} |
|
|
|
onClick={this.getMock}>刷新</Button>; |
|
|
|
}, |
|
|
|
|
|
|
|
render() { |
|
|
|
return <div> |
|
|
|
return ( |
|
|
|
<Transfer |
|
|
|
dataSource={this.state.mockData} |
|
|
|
targetKeys={this.state.targetKeys} |
|
|
|
onChange={this.handleChange} |
|
|
|
render={(item) => { return item.title; }} /> |
|
|
|
</div>; |
|
|
|
render={item => item.title} /> |
|
|
|
); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
ReactDOM.render(<App />, container); |
|
|
|
ReactDOM.render(<App />, document.getElementById('components-transfer-demo-basic')); |
|
|
|
```` |
|
|
|