2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 1
|
2016-07-21 10:10:04 +08:00
|
|
|
title:
|
2017-03-24 19:54:00 +08:00
|
|
|
zh-CN: 单选组合
|
|
|
|
en-US: Radio Group
|
2017-02-20 22:04:17 +08:00
|
|
|
---
|
2016-07-21 10:10:04 +08:00
|
|
|
|
|
|
|
## zh-CN
|
2015-07-17 16:06:46 +08:00
|
|
|
|
2015-08-21 18:24:09 +08:00
|
|
|
一组互斥的 Radio 配合使用。
|
2015-07-17 16:06:46 +08:00
|
|
|
|
2016-07-21 10:10:04 +08:00
|
|
|
## en-US
|
|
|
|
|
2017-03-24 19:54:00 +08:00
|
|
|
A group of radio components.
|
2016-07-21 10:10:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
|
|
|
import type { RadioChangeEvent } from 'antd';
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Radio } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React, { useState } from 'react';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [value, setValue] = useState(1);
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const onChange = (e: RadioChangeEvent) => {
|
2016-02-22 10:52:30 +08:00
|
|
|
console.log('radio checked', e.target.value);
|
2020-11-12 19:54:57 +08:00
|
|
|
setValue(e.target.value);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2020-11-12 19:54:57 +08:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
};
|
2016-03-04 12:07:17 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2016-07-21 10:10:04 +08:00
|
|
|
```
|