我使用的材料-ui自动完成( https://mui.com/components/autocomplete/#free-solo ).
很好,演示在这里:https://codesandbox.io/s/0v9v9?file=/demo.tsx
默认情况下,文本输入显示的是自动完成=‘off’,但我想将其更改为自动完成=‘new--某些东西’,但它不起作用,而且自动完成=‘new--有些东西’显示为父dev属性,而不是输入。
我用了这个代码
<TextField
{...params}
inputProps={{
...params.inputProps,
autoComplete: 'new-something',
}}
/>但这不管用。在输入中,它仍然将autocomplete="off“显示为输入属性。
发布于 2021-10-28 13:25:53
正如您在doc https://mui.com/api/text-field/#props中看到的,有两个道具具有相同的名称。
应用于输入元素的Attributes applied to the input element.
对于自动完成属性,需要inputProps
<TextField
{...params}
label="Search input"
InputProps={
...params.InputProps,
type: 'search',
}}
inputProps={{
autocomplete: 'something'
}}
/>这里是代码框https://codesandbox.io/s/freesolo-material-demo-forked-8g2n1?file=/demo.tsx中的一个工作示例
https://stackoverflow.com/questions/69753285
复制相似问题