inputProps={{ readOnly: true }} 不适用于 Material UI 自动完成

时间:2021-02-01 13:47:37

标签: autocomplete material-ui

我正在尝试将 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 }}
          />
        )}
      />

0 个答案:

没有答案