Browse Source

improve transfer demo code style

pull/774/merge
afc163 9 years ago
parent
commit
4564324621
  1. 22
      components/transfer/demo/advanced.md
  2. 23
      components/transfer/demo/basic.md
  3. 22
      components/transfer/demo/search.md

22
components/transfer/demo/advanced.md

@ -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} />
);
}
});

23
components/transfer/demo/basic.md

@ -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'));
````

22
components/transfer/demo/search.md

@ -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…
Cancel
Save