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

56 lines
1.1 KiB
Markdown
Raw Normal View History

2015-07-16 18:23:25 +08:00
# 组合
- order: 1
Radio 组合。
---
````jsx
var Radio = antd.Radio;
2015-07-16 22:40:49 +08:00
var RadioGroup = React.createClass({
2015-07-16 18:23:25 +08:00
getInitialState() {
return {
2015-07-16 22:40:49 +08:00
};
2015-07-16 18:23:25 +08:00
},
handleChange(e) {
this.setState({
2015-07-16 22:40:49 +08:00
value: e.target.value
2015-07-16 18:23:25 +08:00
});
},
render() {
return <div>
2015-07-16 22:40:49 +08:00
<p>
<label>
<Radio value="a"
checked={this.state.value === 'a'}
onChange={this.handleChange} /> A
</label>
<br/>
<label>
<Radio value="b"
checked={this.state.value === 'b'}
onChange={this.handleChange} /> B
</label>
<br/>
<label>
<Radio value="c"
checked={this.state.value === 'c'}
onChange={this.handleChange} /> C
</label>
<br/>
<label>
<Radio value="d"
checked={this.state.value === 'd'}
onChange={this.handleChange} /> D
</label>
</p>
2015-07-16 18:23:25 +08:00
<p style={{"margin-top": 20}}>
2015-07-16 22:40:49 +08:00
你选中了:{this.state.value} 。
2015-07-16 18:23:25 +08:00
</p>
</div>;
}
});
2015-07-16 22:40:49 +08:00
React.render(<RadioGroup />, document.getElementById('components-radio-demo-group'));
2015-07-16 18:23:25 +08:00
````