我正在尝试将 readOnly 设置为 True 来实现材质 ui 自动完成。我从各种论坛了解到 inputProps 属性会覆盖 params 的 InputProps 参数。但是,我尝试了建议的解决方法,但也失败了。找到下面的代码片段。
<Autocomplete
multiple
id="listvalues"
options={top100Films}
getOptionLabel={(option) => option.title}
filterSelectedOptions
renderInput={(params) => (
<TextField
{...params}
variant="outlined"
label="filterSelectedOptions"
placeholder="Favorites",
inputProps={{...params.inputProps, readOnly: true }}
/>
)}
/>