Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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 无法更新“材质UI”下拉列表中的选定选项_Javascript_Html_Reactjs_Drop Down Menu_Material Ui - Fatal编程技术网

Javascript 无法更新“材质UI”下拉列表中的选定选项

Javascript 无法更新“材质UI”下拉列表中的选定选项,javascript,html,reactjs,drop-down-menu,material-ui,Javascript,Html,Reactjs,Drop Down Menu,Material Ui,我有以下材料界面代码用于选择下拉列表,无法更新下拉列表中的所选选项 <FormControl variant="outlined" className={classes.formControl}> <InputLabel ref={inputLabel} htmlFor="outlined-Name"> Name </InputLabel> <Select value={values.Name}

我有以下
材料界面
代码用于
选择下拉列表
,无法更新下拉列表中的所选选项

 <FormControl variant="outlined" className={classes.formControl}>
    <InputLabel ref={inputLabel} htmlFor="outlined-Name">
      Name
    </InputLabel>
    <Select
      value={values.Name}
      onChange={handleBChange}
      labelWidth={labelWidth}
       inputProps={{
       Name: 'Name',
       id: 'outlined-Name',
     }}
  >
  <MenuItem value="">
   <em>None</em>
  </MenuItem>
  <MenuItem value="1">Name1</MenuItem>
  <MenuItem value="2">Name2</MenuItem>
  <MenuItem value="3">Name3</MenuItem>
  </Select>
  </FormControl>

我的代码出了什么问题?请建议

我认为您需要使用名称而不是名称作为

const handleBChange = event => {
event.preventDefault();
setValues(oldValues => ({
    ...oldValues,
    [event.target.name]: event.target.value,
}));
};

希望它有帮助

很抱歉通知您,但它仍然没有更新值好的,现在,我知道了,连同您的代码,这也需要升级为
inputProps={{name:'name',id:'outlined name',}
const handleBChange = event => {
event.preventDefault();
setValues(oldValues => ({
    ...oldValues,
    [event.target.name]: event.target.value,
}));
};