之前一直使用select组件,却没得要领,每次写起来都贼复杂。原来人家有这么多好的属性你不会用啊。给你你不中用啊[手动刘华强]
点击链接查看,就是这么简单实用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
27const { Select } = antd;
const { Option } = Select;
const children = [];
for (let i = 10; i < 36; i++) {
children.push(<Option key={i} value={i}>{i.toString(36) }:{i}</Option>);
}
function handleChange(value) {
console.log(`selected ${value}`);
}
ReactDOM.render(
<Select
showArrow
showSearch
style={{ width: '100%' }}
placeholder="Please select"
optionFilterProp="children" //设置为 children 表示对内嵌内容进行搜索
onChange={handleChange}
defaultValue={11}
>
{children}
</Select>,
mountNode,
);