ant-design/components/radio/demo/radiogroup.md

46 lines
818 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 1
title:
zh-CN: RadioGroup 组合
en-US: RadioGroup group
-----------------------
## 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
## en-US
A set of mutually exclusive Radio with the use of
2017-01-19 15:19:03 +08:00
```__react
import { Radio } from 'antd';
const RadioGroup = Radio.Group;
2015-07-17 16:06:46 +08:00
const App = React.createClass({
getInitialState() {
2015-07-17 16:06:46 +08:00
return {
2016-03-04 12:07:17 +08:00
value: 1,
2015-07-17 16:06:46 +08:00
};
},
2015-07-21 16:18:27 +08:00
onChange(e) {
console.log('radio checked', e.target.value);
2015-07-17 16:06:46 +08:00
this.setState({
2016-03-04 12:07:17 +08:00
value: e.target.value,
2015-07-21 16:18:27 +08:00
});
2015-07-17 16:06:46 +08:00
},
render() {
return (
2016-03-04 12:07:17 +08:00
<RadioGroup onChange={this.onChange} value={this.state.value}>
2016-11-17 17:50:26 +08:00
<Radio value={1}>A</Radio>
<Radio value={2}>B</Radio>
<Radio value={3}>C</Radio>
<Radio value={4}>D</Radio>
2016-03-04 12:07:17 +08:00
</RadioGroup>
);
2016-05-11 09:32:33 +08:00
},
2015-07-17 16:06:46 +08:00
});
2016-03-04 12:07:17 +08:00
ReactDOM.render(<App />, mountNode);
```