前端项目实战肆佰贰拾叁react-admin和material ui-设置默认值

    <Autocomplete
                            defaultValue={materialList&&materialList[`${Number(line_id)-1}`]}
                            sx={{ width: '400px', alignSelf: 'center', marginTop: '16px' }}
                            disablePortal
                            id='equip_type'
                            options={materialList}
                            onInputChange={(event: any, newValue: string | null) => {
                                //按照名称查找ID
                                const item = materialList.filter((it: any) => it['name'] == newValue);
                                if (item.length > 0) {
                                    equipTypeIdRef.current = item[0].id;
                                }
                            }}
                            renderInput={(params) => <MuiTextField {...params} label='物料类型' />}
                        />

运行结果

 

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