mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
improve transfer demo code style
This commit is contained in:
parent
07656e7c50
commit
4564324621
@ -17,11 +17,9 @@ const App = React.createClass({
|
||||
targetKeys: [],
|
||||
};
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this.getMock();
|
||||
},
|
||||
|
||||
getMock() {
|
||||
let targetKeys = [];
|
||||
let mockData = [];
|
||||
@ -37,25 +35,17 @@ 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="ghost" size="small" style={{ float: 'right', margin: '5' }}
|
||||
onClick={this.getMock}>刷新</Button>;
|
||||
},
|
||||
|
||||
render() {
|
||||
return <div>
|
||||
return (
|
||||
<Transfer
|
||||
dataSource={this.state.mockData}
|
||||
showSearch
|
||||
@ -66,9 +56,9 @@ const App = React.createClass({
|
||||
operations={['向右操作文案', '向左操作文案']}
|
||||
targetKeys={this.state.targetKeys}
|
||||
onChange={this.handleChange}
|
||||
render={(item) => { return item.title + '-' + item.description; }}
|
||||
footer={this.renderFooter}/>
|
||||
</div>;
|
||||
render={item => item.title + '-' + item.description}
|
||||
footer={this.renderFooter} />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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'));
|
||||
````
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
````jsx
|
||||
import { Transfer } from 'antd';
|
||||
const container = document.getElementById('components-transfer-demo-search');
|
||||
|
||||
const App = React.createClass({
|
||||
getInitialState() {
|
||||
@ -17,11 +16,9 @@ const App = React.createClass({
|
||||
targetKeys: [],
|
||||
};
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this.getMock();
|
||||
},
|
||||
|
||||
getMock() {
|
||||
let targetKeys = [];
|
||||
let mockData = [];
|
||||
@ -37,29 +34,22 @@ 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 });
|
||||
},
|
||||
|
||||
render() {
|
||||
return <div>
|
||||
return (
|
||||
<Transfer
|
||||
dataSource={this.state.mockData}
|
||||
showSearch
|
||||
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-search'));
|
||||
````
|
||||
|
Loading…
Reference in New Issue
Block a user