前端项目实战叁佰柒拾玖react-admin和material ui-useRef使用

     <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='部位类型' />}
                        />
  const partIdRef = useRef<number>();

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