单选 html(react)
代码节选
constructor(options) {
super(options);
this.state = {
IsAdmin: true
}
}
<input
type="checkBox"
id="isAdmn"
name="IsAdmin"
onChange={this.handlerChange}
defaultChecked={this.state.IsAdmin}
></input>
// 获取表单的值 并传给state
handlerChange = (e) => {
this.setState({
[e.target.name]: e.target.checked
})
}
本文摘自 :https://www.cnblogs.com/