You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
857 B

9 years ago
# 高级用法
9 years ago
9 years ago
- order: 2
9 years ago
9 years ago
高级用法
9 years ago
---
````jsx
9 years ago
import { Transfer, Button } from 'antd';
9 years ago
const container = document.getElementById('components-transfer-demo-advanced');
9 years ago
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);
9 years ago
````