二货爱吃白萝卜
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
18 additions and
11 deletions
-
components/select/demo/optgroup.md
|
|
@ -17,22 +17,29 @@ Using `OptGroup` to group the options. |
|
|
|
import { Select } from 'antd'; |
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
const { Option, OptGroup } = Select; |
|
|
|
|
|
|
|
const handleChange = (value: string) => { |
|
|
|
console.log(`selected ${value}`); |
|
|
|
}; |
|
|
|
|
|
|
|
const App: React.FC = () => ( |
|
|
|
<Select defaultValue="lucy" style={{ width: 200 }} onChange={handleChange}> |
|
|
|
<OptGroup label="Manager"> |
|
|
|
<Option value="jack">Jack</Option> |
|
|
|
<Option value="lucy">Lucy</Option> |
|
|
|
</OptGroup> |
|
|
|
<OptGroup label="Engineer"> |
|
|
|
<Option value="Yiminghe">yiminghe</Option> |
|
|
|
</OptGroup> |
|
|
|
</Select> |
|
|
|
<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; |
|
|
|