如何清除材料ui自动完成选择值按钮点击反应js?

时间:2017-04-06 09:38:49

标签: reactjs material-ui

我想在点击重置按钮时清除素材ui自动填充选定值?我把这个州变成了空。但仍然没有发生。谁能建议如何实现这一目标?在我的代码下面。

import AutoComplete from 'material-ui/AutoComplete';
import RaisedButton from 'material-ui/RaisedButton';

    const providers = ['aaa', 'aaaaa', 'bbb', 'bbbbb', 'ccc', 'ddd'];
    export default class PhysicianDetails extends React.Component {
      constructor(props) {
        super(props);
        this.state = {provider:''}
    }
    this.providerChange = this.providerChange.bind(this);
    this.handleReset = this.handleReset.bind(this);

    providerChange(value) {debugger;
        this.setState({ provider:value });
      }

    handleReset() {
    this.setState({provider:''});
    }
    render() {
     return(
    <div>
    <AutoComplete floatingLabelText='Providers' filter={AutoComplete.caseInsensitiveFilter} onUpdateInput={this.providerChange} dataSource={providers} />
    <RaisedButton label='reset' onClick={this.handleReset} />
    </div>
    )}
    }

0 个答案:

没有答案