單選 html(react)
代碼節(jié)選
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/