RON*_*ONE 5 javascript checkbox reactjs
在问题标题中,我无法将复选框标记为已选中,如此选择框的onChange事件,
<select id='featuresType'
onChange={this.handleChange.bind(this, 'type')} >
{this.getOptions(featuresType)}
</select>
Run Code Online (Sandbox Code Playgroud)
像handleChange一样:
handleChange: function (field, e) {
if (field == 'type') {
let selected = e.target.value;
this.setState({typeSelected: selected})
}
/*Why the console is taking the previous selecte option, ex: if Locker is selectec below lone prints 'dc' */
console.log(field ,',', this.state.typeSelected)
},
Run Code Online (Sandbox Code Playgroud)
当它绑定到defaultValue时,
defaultChecked={(this.state.typeSelected =='locker')}
checked={(this.state.typeSelected =='locker')}
希望你们有我的问题
这是JSFiddle
我希望复选框可以双向操作,在选择选项时,应选中复选框.此外,用户还可以选中/取消选中Manully复选框
| 归档时间: |
|
| 查看次数: |
238 次 |
| 最近记录: |