0
我正在使用Reactjs。我正在使用Modal from react-bootstrap
創建Modal表單。我使用bootstrap創建了一個表單。該表格包含默認情況下需要檢查的複選框。所以我使用checked
屬性作爲輸入複選框。但是當我點擊它時,複選框不會切換。我無法弄清楚這個問題。這裏是我的代碼:默認選中的複選框不會在點擊時切換
<Modal show={this.state.showModal} onHide={this.closeModal}>
<Modal.Header closeButton>
<Modal.Title>Create New User</Modal.Title>
</Modal.Header>
<Modal.Body>
<form class="form-horizontal" name="newUser">
<div class="form-group">
<label class="control-label col-md-4" for="userName">User Name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="userName" ref="userName" placeholder="User Name"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="password">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" id="password" ref="password" placeholder="Enter Password"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="password">Confirm Password</label>
<div class="col-md-6">
<input type="password" class="form-control" id="confirmPassword" ref="password" placeholder="Re-enter Password"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="email">Email Address</label>
<div class="col-md-6">
<input type="email" class="form-control" id="email" ref="email" placeholder="Email Address"/>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-4 col-md-6">
<div class="checkbox-inline">
<label><input type="checkbox" id="enabled" ref="enabled" value="enabled" checked/> Enabled </label>
</div>
<div class="checkbox-inline">
<label><input type="checkbox" id="locked" ref="locked" value="locked" /> Locked </label>
</div>
</div>
</div>
</form>
</Modal.Body>
<Modal.Footer>
<Button onClick={this.submitUser} bsStyle="primary">Confirm</Button>
<Button onClick={this.closeModal} bsStyle="warning">Cancel</Button>
</Modal.Footer>
</Modal>