mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
47 lines
749 B
Markdown
47 lines
749 B
Markdown
---
|
|
order: 6
|
|
title:
|
|
zh-CN: 分组
|
|
en-US: Option Group
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
用 `OptGroup` 进行选项分组。
|
|
|
|
## en-US
|
|
|
|
Using `OptGroup` to group the options.
|
|
|
|
```tsx
|
|
import { Select } from 'antd';
|
|
import React from 'react';
|
|
|
|
const handleChange = (value: string) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Select
|
|
defaultValue="lucy"
|
|
style={{ width: 200 }}
|
|
onChange={handleChange}
|
|
options={[
|
|
{
|
|
label: 'Manager',
|
|
options: [
|
|
{ label: 'Jack', value: 'jack' },
|
|
{ label: 'Lucy', value: 'lucy' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Engineer',
|
|
options: [{ label: 'yiminghe', value: 'Yiminghe' }],
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
|
|
export default App;
|
|
```
|