mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 00:08:27 +08:00
e7aa014c31
* docs: init * chore: all types * docs: faq * chore: fix lint
41 lines
1000 B
TypeScript
41 lines
1000 B
TypeScript
import React from 'react';
|
|
import { Checkbox } from 'antd';
|
|
import type { GetProp } from 'antd';
|
|
|
|
const onChange: GetProp<typeof Checkbox.Group, 'onChange'> = (checkedValues) => {
|
|
console.log('checked = ', checkedValues);
|
|
};
|
|
|
|
const plainOptions = ['Apple', 'Pear', 'Orange'];
|
|
|
|
const options = [
|
|
{ label: 'Apple', value: 'Apple' },
|
|
{ label: 'Pear', value: 'Pear' },
|
|
{ label: 'Orange', value: 'Orange' },
|
|
];
|
|
|
|
const optionsWithDisabled = [
|
|
{ label: 'Apple', value: 'Apple' },
|
|
{ label: 'Pear', value: 'Pear' },
|
|
{ label: 'Orange', value: 'Orange', disabled: false },
|
|
];
|
|
|
|
const App: React.FC = () => (
|
|
<>
|
|
<Checkbox.Group options={plainOptions} defaultValue={['Apple']} onChange={onChange} />
|
|
<br />
|
|
<br />
|
|
<Checkbox.Group options={options} defaultValue={['Pear']} onChange={onChange} />
|
|
<br />
|
|
<br />
|
|
<Checkbox.Group
|
|
options={optionsWithDisabled}
|
|
disabled
|
|
defaultValue={['Apple']}
|
|
onChange={onChange}
|
|
/>
|
|
</>
|
|
);
|
|
|
|
export default App;
|