2017-08-16 26 views
0

我已经用ReactJS创建了Meteor项目。 对于创建/编辑页面,我用的是同一个页面,在文字输入,我有以下代码:如何在文本等选择选项中使用name,ref,defaultValue? - 在React流星

<FormGroup> 
<ControlLabel>Province</ControlLabel> 
    <input 
     type="text" 
     className="form-control" 
     name="province" 
     ref={province => (this.province = province)} 
     defaultValue={regs && regs.province} 
    /> 
</FormGroup> 

要得到相同的结果。 如何在select-option,checkbox,radio,..等中使用name,ref,defaultValue。像文字?

<FormGroup controlId="formControlsSelect"> 
    <ControlLabel>Sex</ControlLabel> 
    <FormControl componentClass="select" name="sex" ref={sex => (this.sex = sex)} defaultValue={regs && regs.sex}> 
    <option value="male">Male</option> 
    <option value="female">Female</option> 
    </FormControl> 
</FormGroup> 
+1

'name'和'ref'工作与他们相同的解决这个问题,'defaultValue'工作的''