ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
Autocomplete ``` onChang({ current }) { this.setState({ current, datasets: current === 1 ? datasets : datasets2, value : val }); } onSelect(val){ console.log(val) this.setState({ value : val }) } DefaultProps(){ console.log('getDefaultProps'); } function(props) { return <input {...props} /> } componentDidMount(){ const datasource = []; jQuery(($)=>{ $(ReactDOM.findDOMNode()).autocomplete({ sources:datasource }) }) } ``` ``` <Autocomplete getItemValue={(item) => item.label} items={[ { label: 'apple' ,id:1 }, { label: 'banana', id:2}, { label: 'pear', id:3} ]} renderItem={(item, isHighlighted,index) => <div key={item.id} style={{ background: isHighlighted ? 'lightgray' : 'white' }}> {item.label} </div> } const value = '' value={this.value} //onChange={this.onChange(value)} // onSelect={this.onSelect(val)} onSelect={(e) => { console.log(e) ReactDOM.findDOMNode().value = e }} /> ```