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.
|
|
|
---
|
|
|
|
order: 0
|
|
|
|
title:
|
|
|
|
zh-CN: 基本使用
|
|
|
|
en-US: Basic Usage
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
基本使用。通过 dataSource 设置自动完成的数据源
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Basic Usage, set datasource of autocomplete with `dataSource` property.
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { AutoComplete } from 'antd';
|
|
|
|
|
|
|
|
function onSelect(value) {
|
|
|
|
console.log('onSelect', value);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Complete = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
dataSource: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
handleChange(value) {
|
|
|
|
this.setState({
|
|
|
|
dataSource: !value ? [] : [
|
|
|
|
value,
|
|
|
|
value + value,
|
|
|
|
value + value + value,
|
|
|
|
],
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
const { dataSource } = this.state;
|
|
|
|
return (
|
|
|
|
<AutoComplete
|
|
|
|
dataSource={dataSource}
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onSelect={onSelect}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
ReactDOM.render(<Complete />, mountNode);
|
|
|
|
````
|