mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
|
import React, { useState } from 'react';
|
||
|
import { Radio, Select } from 'antd';
|
||
|
import type { SizeType } from 'antd/es/config-provider/SizeContext';
|
||
|
import type { SelectProps, RadioChangeEvent } from 'antd';
|
||
|
|
||
|
const options: SelectProps['options'] = [];
|
||
|
for (let i = 10; i < 36; i++) {
|
||
|
options.push({
|
||
|
value: i.toString(36) + i,
|
||
|
label: i.toString(36) + i,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
const handleChange = (value: string | string[]) => {
|
||
|
console.log(`Selected: ${value}`);
|
||
|
};
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [size, setSize] = useState<SizeType>('middle');
|
||
|
|
||
|
const handleSizeChange = (e: RadioChangeEvent) => {
|
||
|
setSize(e.target.value);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Radio.Group value={size} onChange={handleSizeChange}>
|
||
|
<Radio.Button value="large">Large</Radio.Button>
|
||
|
<Radio.Button value="default">Default</Radio.Button>
|
||
|
<Radio.Button value="small">Small</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
<br />
|
||
|
<br />
|
||
|
<Select
|
||
|
size={size}
|
||
|
defaultValue="a1"
|
||
|
onChange={handleChange}
|
||
|
style={{ width: 200 }}
|
||
|
options={options}
|
||
|
/>
|
||
|
<br />
|
||
|
<Select
|
||
|
mode="multiple"
|
||
|
size={size}
|
||
|
placeholder="Please select"
|
||
|
defaultValue={['a10', 'c12']}
|
||
|
onChange={handleChange}
|
||
|
style={{ width: '100%' }}
|
||
|
options={options}
|
||
|
/>
|
||
|
<br />
|
||
|
<Select
|
||
|
mode="tags"
|
||
|
size={size}
|
||
|
placeholder="Please select"
|
||
|
defaultValue={['a10', 'c12']}
|
||
|
onChange={handleChange}
|
||
|
style={{ width: '100%' }}
|
||
|
options={options}
|
||
|
/>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|