我想在此UI实质自动组件的下拉列表中预先选择一个值,它在更新详细信息页面上,我该如何设置?这是我的下面的代码
<FormControl variant="outlined" fullWidth>
<Autocomplete
id="combo-box-demo"
options={props.options}
getOptionLabel={option => option.label}
onChange={(event, newValue) => {
if (props.selectedValue) props.selectedValue(newValue);
if (props.getvalue) props.getvalue(newValue.id);
}}
renderInput={params => (
<TextField
{...params}
size="small"
variant="outlined"
className="formField"
name={props.name}
inputRef={props.register}
/>
)}
/>
</FormControl>
答案 0 :(得分:1)
将占位符添加到TextField中,如:
<TextField
{...params}
placeholder ={ "The value that you want to set as preselected" }
size="small"
variant="outlined"
className="formField"
name={props.name}
inputRef={props.register}
/>