Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Reactjs-带有FormControlLabel的材质ui单选按钮-不工作_Javascript_Reactjs_Material Ui - Fatal编程技术网

Javascript Reactjs-带有FormControlLabel的材质ui单选按钮-不工作

Javascript Reactjs-带有FormControlLabel的材质ui单选按钮-不工作,javascript,reactjs,material-ui,Javascript,Reactjs,Material Ui,我正在尝试使用material ui中的单选按钮- 虽然这里的示例没有提供提交表单时选择的单选按钮。我也尝试使用redux表单,但是它们的文档似乎已经过时了。例如,我不确定您将如何预先选择单选按钮 renderRadioGroup.js import React from 'react'; import Radio from '@material-ui/core/Radio'; import RadioGroup from '@material-ui/core/RadioGroup'; impo

我正在尝试使用material ui中的单选按钮-

虽然这里的示例没有提供提交表单时选择的单选按钮。我也尝试使用redux表单,但是它们的文档似乎已经过时了。例如,我不确定您将如何预先选择单选按钮

renderRadioGroup.js

import React from 'react';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl';
import FormLabel from '@material-ui/core/FormLabel';


const renderRadioGroup = ({ input, label, value, fieldName, handleChange, options, meta: { touched, error }}) => (
    <FormControl component="fieldset" fullWidth={true}>
      <FormLabel component="legend">{label} {value}</FormLabel>
      <RadioGroup 
        row 
        aria-label={fieldName} 
        name={fieldName} 
        value={value}
        onChange={handleChange}
        >
        {
            options.map((item, j) =>
                <FormControlLabel key={j} value={item.value} disabled={item.disabled} control={<Radio />} label={item.label} />
            )
        }
      </RadioGroup>
    </FormControl>
)

export default renderRadioGroup;
从“React”导入React;
从“@material ui/core/Radio”导入无线电;
从“@material ui/core/RadioGroup”导入射线组;
从“@material ui/core/FormControlLabel”导入FormControlLabel;
从“@material ui/core/FormControl”导入FormControl;
从“@material ui/core/FormLabel”导入FormLabel;
const renderRadioGroup=({input,label,value,fieldName,handleChange,options,meta:{toucted,error}})=>(
{label}{value}
{
选项.map((项目,j)=>
)
}
)
导出默认渲染器组;


我建议使用或,因为他们有很好的文档。但这对使用材质ui库及其动画/ui等并没有什么帮助。。它只是单选按钮,似乎没有采取
  <Field 
    name="paymentplan" 
    component={renderRadioGroup} 
    label="Do you wish to pay monthly or annually?" 
    value={"1"} 
    fieldName="paymentplan" 
    options={
      [
        {
          "label" : "Monthly",
          "value" : "0"
        },
        {
          "label" : "Annually",
          "value" : "1"
        }
      ]
    }
    />