javascript - react,獲取radio的值出錯
問題描述
代碼是這樣的(刪了一部分,只留了有問題的
class NewGateway extends React.Component { handleSubmit(e) {var gw = form2json(’#newGatewayForm’);console.log('gw', gw); } render() {return <Form horizontal id='newGatewayForm'> <FormGroup controlId='formRegister'><Col componentClass={ControlLabel} sm={2}><T.span text='Register'/></Col><Col sm={10}> <Radio name='register' value='yes' inline><T.span text='yes'/></Radio> <Radio name='register' value='no' inline><T.span text='no'/></Radio></Col> </FormGroup></Form> }}
獲取gw.register,總是獲得no,就是無論選哪個radio,得到的都是后面那個radio的值。
問一下原因和怎么修改
問題解答
回答1:form2json 是哪個庫的? 建議 react 應該用 state 去管理 radio 的值.(包括其他 form 元素)
相關文章:
1. javascript - react native在run-android時出現(xiàn)這個錯誤該怎么解決?大神賜教2. javascript - react如何獲取offsetX?3. javascript - react native 使用fetch 向后端傳數(shù)據(jù)提示錯誤4. javascript - REACT組件的樣式問題5. javascript - react能夠使用什么時間插件6. javascript - react 組件props和state的問題7. javascript - react 的問題,標題不知怎么起...8. javascript - react性能問題?9. javascript - Reactjs關于函數(shù)內跳轉 this.context.router.push(path)的問題10. javascript - react 里使用antd model 怎么控制model 開關
