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时出现这个错误该怎么解决?大神赐教2. javascript - react 中各个声明周期中异步的执行顺序3. javascript - react配合fetch报错问题4. javascript - react 从对象中获取图片5. javascript - react 里使用antd model 怎么控制model 开关6. javascript - React中组件绑定this7. javascript - react-router路有嵌套问题?8. javascript - react的ui库问题9. javascript - REACT组件的样式问题10. javascript - react 组件props和state的问题
