docs: Update demo (#39127)

This commit is contained in:
二货爱吃白萝卜 2022-11-30 22:51:06 +08:00 committed by GitHub
parent aa1945d9ae
commit 88e360d79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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