mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
41 lines
733 B
Markdown
41 lines
733 B
Markdown
---
|
|
order: 1
|
|
title:
|
|
zh-CN: 单选组合
|
|
en-US: Radio Group
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
一组互斥的 Radio 配合使用。
|
|
|
|
## en-US
|
|
|
|
A group of radio components.
|
|
|
|
```tsx
|
|
import type { RadioChangeEvent } from 'antd';
|
|
import { Radio } from 'antd';
|
|
import React, { useState } from 'react';
|
|
|
|
const App: React.FC = () => {
|
|
const [value, setValue] = useState(1);
|
|
|
|
const onChange = (e: RadioChangeEvent) => {
|
|
console.log('radio checked', e.target.value);
|
|
setValue(e.target.value);
|
|
};
|
|
|
|
return (
|
|
<Radio.Group onChange={onChange} value={value}>
|
|
<Radio value={1}>A</Radio>
|
|
<Radio value={2}>B</Radio>
|
|
<Radio value={3}>C</Radio>
|
|
<Radio value={4}>D</Radio>
|
|
</Radio.Group>
|
|
);
|
|
};
|
|
|
|
export default App;
|
|
```
|