Browse Source

docs: Update demo (#39127)

pull/39332/head
二货爱吃白萝卜 2 years ago
committed by GitHub
parent
commit
88e360d79d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      components/select/demo/optgroup.md

29
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;

Loading…
Cancel
Save