2015-12-18 09:05:02 +08:00
|
|
|
# 高级用法
|
2015-11-25 23:17:06 +08:00
|
|
|
|
2015-12-18 09:05:02 +08:00
|
|
|
- order: 2
|
2015-11-25 23:17:06 +08:00
|
|
|
|
2015-12-18 09:05:02 +08:00
|
|
|
高级用法
|
2015-11-25 23:17:06 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-12-18 09:05:02 +08:00
|
|
|
import { Transfer, Button } from 'antd';
|
2015-11-25 23:17:06 +08:00
|
|
|
const container = document.getElementById('components-transfer-demo-advanced');
|
|
|
|
|
2015-12-18 09:05:02 +08:00
|
|
|
const App = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
mockData: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.getMock();
|
|
|
|
},
|
|
|
|
|
|
|
|
getMock() {
|
|
|
|
let mockData = [];
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
|
|
mockData.push({
|
|
|
|
title: '内容' + (i + 1),
|
|
|
|
value: (i + 1),
|
|
|
|
description: '内容' + (i + 1) + '的描述',
|
|
|
|
chosen: Math.random() * 2 > 1
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
mockData: mockData
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return <div>
|
|
|
|
<Transfer defaultDataSource={this.state.mockData} />
|
|
|
|
<Button onClick={this.getMock}>刷新数据</Button>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, container);
|
2015-11-25 23:17:06 +08:00
|
|
|
````
|