具有自动完成文本字段的材质UI始终显示自动填充

我正在使用Material UI自动完成:

import TextField from "@material-ui/core/TextField";
import Autocomplete from "@material-ui/lab/Autocomplete";
import parse from "autosuggest-highlight/parse";
import match from "autosuggest-highlight/match";

   <Autocomplete
                id="cityAutocomplete"
                options={cities}
                // onChange={(event,value) => console.log(value)} // prints the selected value
                onChange={(event,value) => callback(value)}
                getOptionLabel={option => option.title}
                renderInput={params => (
                    <TextField
                        {...params}
                        variant="outlined"
                        fullWidth
                        type='text'
                        autoComplete="off"
                        placeholder="Enter City"
                    />
                )}
                renderOption={(option,{ inputvalue }) => {
                    const matches = match(option.title,inputvalue);
                    const parts = parse(option.title,matches);

                    return (
                        <div>
                            {parts.map((part,index) => (
                                <span
                                    key={index}
                                    style={{ fontWeight: part.highlight ? 700 : 400 }}
                                >
                                    {part.text}
                                </span>
                            ))}
                        </div>
                    );
                }}
            />

当用户开始输入TextField时,总是会提示已提交的先前值。

如何防止TextField显示自动填充?

我添加了autoComplete="off",但仍在发生。

qiaodayu 回答:具有自动完成文本字段的材质UI始终显示自动填充

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3046246.html

大家都在问