You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
824 B

# RadioGroup 组合
9 years ago
- order: 1
一组互斥的 Radio 配合使用。
9 years ago
---
````jsx
var Radio = antd.Radio;
var RadioGroup = antd.Radio.Group;
9 years ago
9 years ago
var App = React.createClass({
9 years ago
getInitialState: function () {
return {
value: 'a'
9 years ago
};
},
onChange(e) {
console.log('radio checked:' + e.target.value);
9 years ago
this.setState({
value: e.target.value
});
9 years ago
},
render() {
return <div>
<RadioGroup onChange={this.onChange} value={this.state.value}>
<Radio value="a">A</Radio>
<Radio value="b">B</Radio>
<Radio value="c">C</Radio>
<Radio value="d">D</Radio>
9 years ago
</RadioGroup>
<div style={{marginTop: 20}}>你选中的: {this.state.value}</div>
</div>;
9 years ago
}
});
9 years ago
ReactDOM.render(<App />, document.getElementById('components-radio-demo-radiogroup'));
9 years ago
````