2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
|
|
|
|
order: 2
|
2016-07-21 10:10:04 +08:00
|
|
|
|
title:
|
|
|
|
|
zh-CN: RadioGroup 垂直
|
|
|
|
|
en-US: Vertical RadioGroup
|
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
|
|
|
|
|
|
|
|
|
垂直的 RadioGroup,配合更多输入框选项。
|
|
|
|
|
|
2016-07-21 10:10:04 +08:00
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
|
|
Vertical RadioGroup, with more radios.
|
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
|
```jsx
|
2016-03-04 16:30:17 +08:00
|
|
|
|
import { Radio, Input } from 'antd';
|
|
|
|
|
const RadioGroup = Radio.Group;
|
|
|
|
|
|
2017-02-20 22:04:17 +08:00
|
|
|
|
class App extends React.Component {
|
|
|
|
|
state = {
|
|
|
|
|
value: 1,
|
|
|
|
|
}
|
|
|
|
|
onChange = (e) => {
|
2016-03-04 16:30:17 +08:00
|
|
|
|
console.log('radio checked', e.target.value);
|
|
|
|
|
this.setState({
|
|
|
|
|
value: e.target.value,
|
|
|
|
|
});
|
2017-02-20 22:04:17 +08:00
|
|
|
|
}
|
2016-03-04 16:30:17 +08:00
|
|
|
|
render() {
|
|
|
|
|
const radioStyle = {
|
|
|
|
|
display: 'block',
|
|
|
|
|
height: '30px',
|
|
|
|
|
lineHeight: '30px',
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
2016-11-17 17:50:26 +08:00
|
|
|
|
<Radio style={radioStyle} value={1}>Option A</Radio>
|
|
|
|
|
<Radio style={radioStyle} value={2}>Option B</Radio>
|
|
|
|
|
<Radio style={radioStyle} value={3}>Option C</Radio>
|
|
|
|
|
<Radio style={radioStyle} value={4}>
|
2016-03-04 16:30:17 +08:00
|
|
|
|
More...
|
|
|
|
|
{this.state.value === 4 ? <Input style={{ width: 100, marginLeft: 10 }} /> : null}
|
|
|
|
|
</Radio>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
);
|
2017-02-20 22:04:17 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-04 16:30:17 +08:00
|
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
2016-07-21 10:10:04 +08:00
|
|
|
|
```
|