2017-08-16 50 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'工作的''