2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
|
|
|
|
order: 2
|
2016-07-21 10:10:04 +08:00
|
|
|
|
title:
|
2019-05-27 21:32:45 +08:00
|
|
|
|
zh-CN: Radio.Group 垂直
|
|
|
|
|
en-US: Vertical Radio.Group
|
2017-02-20 22:04:17 +08:00
|
|
|
|
---
|
2016-07-21 10:10:04 +08:00
|
|
|
|
|
|
|
|
|
## zh-CN
|
2016-03-04 16:30:17 +08:00
|
|
|
|
|
2019-05-27 21:32:45 +08:00
|
|
|
|
垂直的 Radio.Group,配合更多输入框选项。
|
2016-03-04 16:30:17 +08:00
|
|
|
|
|
2016-07-21 10:10:04 +08:00
|
|
|
|
## en-US
|
|
|
|
|
|
2019-05-27 21:32:45 +08:00
|
|
|
|
Vertical Radio.Group, with more radios.
|
2016-07-21 10:10:04 +08:00
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
|
```jsx
|
2021-04-22 20:15:23 +08:00
|
|
|
|
import { Radio, Input, Space } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
|
2017-02-20 22:04:17 +08:00
|
|
|
|
class App extends React.Component {
|
|
|
|
|
state = {
|
|
|
|
|
value: 1,
|
2019-05-07 14:57:32 +08:00
|
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
|
onChange = e => {
|
2016-03-04 16:30:17 +08:00
|
|
|
|
console.log('radio checked', e.target.value);
|
|
|
|
|
this.setState({
|
|
|
|
|
value: e.target.value,
|
|
|
|
|
});
|
2019-05-07 14:57:32 +08:00
|
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
|
2016-03-04 16:30:17 +08:00
|
|
|
|
render() {
|
2020-03-30 22:14:13 +08:00
|
|
|
|
const { value } = this.state;
|
2016-03-04 16:30:17 +08:00
|
|
|
|
return (
|
2020-03-30 22:14:13 +08:00
|
|
|
|
<Radio.Group onChange={this.onChange} value={value}>
|
2021-04-22 20:15:23 +08:00
|
|
|
|
<Space direction="vertical">
|
|
|
|
|
<Radio value={1}>Option A</Radio>
|
|
|
|
|
<Radio value={2}>Option B</Radio>
|
|
|
|
|
<Radio value={3}>Option C</Radio>
|
|
|
|
|
<Radio value={4}>
|
|
|
|
|
More...
|
|
|
|
|
{value === 4 ? <Input style={{ width: 100, marginLeft: 10 }} /> : null}
|
|
|
|
|
</Radio>
|
|
|
|
|
</Space>
|
2019-05-27 21:32:45 +08:00
|
|
|
|
</Radio.Group>
|
2016-03-04 16:30:17 +08:00
|
|
|
|
);
|
2017-02-20 22:04:17 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-04 16:30:17 +08:00
|
|
|
|
|
2022-04-03 23:27:45 +08:00
|
|
|
|
export default () => <App />;
|
2016-07-21 10:10:04 +08:00
|
|
|
|
```
|