forked from react-component/select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmul-suggest.js
59 lines (52 loc) · 1.23 KB
/
mul-suggest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* eslint no-console: 0 */
import React from 'react';
import Select, { Option } from 'rc-select';
import 'rc-select/assets/index.less';
import { fetch } from './common/tbFetchSuggest';
import ReactDOM from 'react-dom';
class Search extends React.Component {
state = {
data: [],
value: [],
};
onChange = (value) => {
console.log('onChange ', value);
this.setState({
value,
});
};
fetchData = (value) => {
fetch(value, (data) => {
this.setState({
data,
});
});
};
render() {
const data = this.state.data;
const options = data.map((d) => {
return <Option key={d.value}><i>{d.text}</i></Option>;
});
return (<div>
<h2>multiple suggest</h2>
<div>
<Select
value={this.state.value}
labelInValue
style={{ width: 500 }}
animation="slide-up"
placeholder="搜索下"
optionLabelProp="children"
multiple
notFoundContent=""
onSearch={this.fetchData}
onChange={this.onChange}
filterOption={false}
>
{options}
</Select>
</div>
</div>);
}
}
ReactDOM.render(<Search />, document.getElementById('__react-content'));