mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 20:49:14 +08:00
59 lines
1.0 KiB
Markdown
59 lines
1.0 KiB
Markdown
---
|
|
order: 2
|
|
title:
|
|
zh-CN: 多选
|
|
en-US: multiple selection
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
多选,从已有条目中选择。
|
|
|
|
## en-US
|
|
|
|
Multiple selection, selecting from existing items.
|
|
|
|
```tsx
|
|
import { Select } from 'antd';
|
|
import React from 'react';
|
|
|
|
const { Option } = Select;
|
|
|
|
const children: React.ReactNode[] = [];
|
|
for (let i = 10; i < 36; i++) {
|
|
children.push(<Option key={i.toString(36) + i}>{i.toString(36) + i}</Option>);
|
|
}
|
|
|
|
const handleChange = (value: string[]) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<>
|
|
<Select
|
|
mode="multiple"
|
|
allowClear
|
|
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>
|
|
</>
|
|
);
|
|
|
|
export default App;
|
|
```
|