ant-design/components/auto-complete/demo/basic.md
2016-08-23 21:00:35 +08:00

771 B

order title
0
zh-CN en-US
基本使用 Basic Usage

zh-CN

基本使用。通过 dataSource 设置自动完成的数据源

en-US

Basic Usage, set datasource of autocomplete with dataSource property.

import { AutoComplete } from 'antd';

const Complete = React.createClass({
  getInitialState() {
    return {
      dataSource: [],
    };
  },
  handleChange(value) {
    this.setState({
      dataSource: [
        value,
        value + value,
        value + value + value,
      ],
    });
  },
  render() {
    const { dataSource } = this.state;
    return (<AutoComplete
      dataSource={dataSource}
      style={{ width: 200 }}
      onChange={this.handleChange}
    />);
  },
});

ReactDOM.render(<Complete />, mountNode);