ant-design/components/select/demo/multiple.md

56 lines
934 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 2
2016-08-28 17:47:06 +08:00
title:
2016-07-10 08:55:43 +08:00
zh-CN: 多选
2016-09-01 18:12:12 +08:00
en-US: multiple selection
2016-03-31 09:40:55 +08:00
---
2015-06-09 21:16:59 +08:00
2016-07-10 08:55:43 +08:00
## zh-CN
多选,从已有条目中选择。
2015-06-09 21:16:59 +08:00
2016-07-10 08:55:43 +08:00
## en-US
Multiple selection, selecting from existing items.
2016-07-10 08:55:43 +08:00
2019-05-07 14:57:32 +08:00
```jsx
import { Select } from 'antd';
2018-06-27 15:55:04 +08:00
const { Option } = Select;
2015-06-09 21:16:59 +08:00
2016-08-28 17:47:06 +08:00
const children = [];
for (let i = 10; i < 36; i++) {
2015-07-08 22:07:15 +08:00
children.push(<Option key={i.toString(36) + i}>{i.toString(36) + i}</Option>);
2015-06-09 21:16:59 +08:00
}
function handleChange(value) {
console.log(`selected ${value}`);
2015-06-09 21:16:59 +08:00
}
2015-10-20 16:47:55 +08:00
ReactDOM.render(
<>
<Select
mode="multiple"
style={{ width: '100%' }}
placeholder="Please select"
defaultValue={['a10', 'c12']}
onChange={handleChange}
>
{children}
</Select>
<br />
<Select
mode="multiple"
disabled
style={{ width: '100%' }}
placeholder="Please select"
defaultValue={['a10', 'c12']}
onChange={handleChange}
>
{children}
</Select>
</>,
2019-05-07 14:57:32 +08:00
mountNode,
2018-11-28 15:00:03 +08:00
);
2019-05-07 14:57:32 +08:00
```