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
|
|
|
|
|
2019-05-22 19:33:03 +08:00
|
|
|
多选,从已有条目中选择。
|
2015-06-09 21:16:59 +08:00
|
|
|
|
2016-07-10 08:55:43 +08:00
|
|
|
## en-US
|
|
|
|
|
2019-05-22 19:33:03 +08:00
|
|
|
Multiple selection, selecting from existing items.
|
2016-07-10 08:55:43 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Select } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2022-09-19 18:01:16 +08:00
|
|
|
import type { SelectProps } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-09-19 18:01:16 +08:00
|
|
|
const options: SelectProps['options'] = [];
|
2015-10-28 20:55:49 +08:00
|
|
|
for (let i = 10; i < 36; i++) {
|
2022-09-19 18:01:16 +08:00
|
|
|
options.push({
|
|
|
|
label: i.toString(36) + i,
|
|
|
|
value: i.toString(36) + i,
|
|
|
|
});
|
2015-06-09 21:16:59 +08:00
|
|
|
}
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const handleChange = (value: string[]) => {
|
2016-02-17 18:04:42 +08:00
|
|
|
console.log(`selected ${value}`);
|
2022-05-19 09:46:26 +08:00
|
|
|
};
|
2015-06-09 21:16:59 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2020-08-04 11:56:18 +08:00
|
|
|
<>
|
|
|
|
<Select
|
|
|
|
mode="multiple"
|
2020-08-26 17:50:14 +08:00
|
|
|
allowClear
|
2020-08-04 11:56:18 +08:00
|
|
|
style={{ width: '100%' }}
|
|
|
|
placeholder="Please select"
|
|
|
|
defaultValue={['a10', 'c12']}
|
|
|
|
onChange={handleChange}
|
2022-09-19 18:01:16 +08:00
|
|
|
options={options}
|
|
|
|
/>
|
2020-08-04 11:56:18 +08:00
|
|
|
<br />
|
|
|
|
<Select
|
|
|
|
mode="multiple"
|
|
|
|
disabled
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
placeholder="Please select"
|
|
|
|
defaultValue={['a10', 'c12']}
|
|
|
|
onChange={handleChange}
|
2022-09-19 18:01:16 +08:00
|
|
|
options={options}
|
|
|
|
/>
|
2022-04-03 23:27:45 +08:00
|
|
|
</>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|