當前位置:首頁 > IT技術 > Web編程 > 正文

單選 html
2021-10-20 10:29:26

單選 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/

開通會員,享受整站包年服務立即開通 >