我有一个反应表,可用于添加和编辑数据。 尝试编辑记录时,除自动完成记录外,我的所有数据均正确显示在文本字段中,我知道在道具中进行验证时会正确携带数据。
使用以下代码,我尝试过的是,如果道具中的id为0,即它是一条新记录,则采用自动完成值,如果不采用我带入道具的值,但是文本框仍显示为空白,可能是什么问题?
<Autocomplete}
{...defaultProps}
id="TypeAuto"
autoComplete
includeInputInList
value={(props.theregistry.id===0) ? dataAutoComplete.TypeAuto : props.theregistry.tipos}
onChange={(event, newVal)=>handleChangeAutoType({target:{name:"TypeAuto",value: newVal
}
})}
renderInput={params => (
<TextField {...params} label="Types" margin="normal" variant="outlined" fullWidth="true" />
)}
/>