mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
docs: update demos of AutoComplete, close: #3106
This commit is contained in:
parent
247757f63f
commit
c1d71acfc7
@ -33,11 +33,13 @@ const Complete = React.createClass({
|
||||
},
|
||||
render() {
|
||||
const { dataSource } = this.state;
|
||||
return (<AutoComplete
|
||||
dataSource={dataSource}
|
||||
style={{ width: 200 }}
|
||||
onChange={this.handleChange}
|
||||
/>);
|
||||
return (
|
||||
<AutoComplete
|
||||
dataSource={dataSource}
|
||||
style={{ width: 200 }}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -22,28 +22,30 @@ const Option = AutoComplete.Option;
|
||||
const Complete = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
dataSource: [],
|
||||
result: [],
|
||||
};
|
||||
},
|
||||
handleChange(value) {
|
||||
let dataSource;
|
||||
let result;
|
||||
if (!value || value.indexOf('@') >= 0) {
|
||||
dataSource = [];
|
||||
result = [];
|
||||
} else {
|
||||
dataSource = ['gmail.com', '163.com', 'qq.com'].map((domain) => {
|
||||
const email = `${value}@${domain}`;
|
||||
return <Option key={email}>{email}</Option>;
|
||||
});
|
||||
result = ['gmail.com', '163.com', 'qq.com'].map(domain => `${value}@${domain}`);
|
||||
}
|
||||
this.setState({ dataSource });
|
||||
this.setState({ result });
|
||||
},
|
||||
render() {
|
||||
const { dataSource } = this.state;
|
||||
return (<AutoComplete
|
||||
style={{ width: 200 }}
|
||||
dataSource={dataSource}
|
||||
onChange={this.handleChange}
|
||||
/>);
|
||||
const { result } = this.state;
|
||||
const dataSource = result.map((email) => {
|
||||
return <Option key={email}>{email}</Option>;
|
||||
});
|
||||
return (
|
||||
<AutoComplete
|
||||
style={{ width: 200 }}
|
||||
dataSource={dataSource}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user