前端项目实战叁佰捌拾react-admin和material ui-下拉框得显示

 <Autocomplete
  sx={{ width: '400px', alignSelf: 'center', marginTop: '16px' }}
  disablePortal
  id='equip_type'
   options={partList}
   getOptionLabel={(option: any) => option.part_name}
   onInputChange={(event: any, newValue: string | null) => {
  //按照名称查找ID
const item = partList.filter((it: any) => it['part_name'] === newValue);
   if (item.length > 0) {
    partIdRef.current = item[0].id;
    }
 }}
 renderInput={(params) => <MuiTextField {...params} label='部位类型' />}
/>

运行结果

posted @ 2023-09-06 11:34  前端导师歌谣  阅读(9)  评论(0)    收藏  举报  来源