前端项目实战肆佰贰拾叁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='物料类型' />}
/>
运行结果


浙公网安备 33010602011771号