我正在尝试在我的项目中实现自动完成组件,但一段时间后我从浏览器获取自动填充/自动完成。你知道我怎么能把它关掉吗?
<Autocomplete
id="combo-box-demo"
options={battleRepos}
getOptionLabel={option => option.full_name}
style={{ width: 500 }}
renderInput={params => (
<TextField {...params}
label="Combo box"
variant="outlined"
onBlur={event => console.log(event.target.value)}
fullWidth />
)}
/>
最佳答案
更新
随着@material-ui/core 4.7.0 和@material-ui/lab 4.0.0-alpha.33 的发布,此问题现已修复,不再需要如下所示的解决方法。
这已在最近的 pull request 中修复,但尚未发布(将在下一个版本中发布)。
如果你想在发布之前解决这个问题(可能会在几天内),你可以像下面这样设置 inputProps.autoComplete = "off"
:
<Autocomplete
id="combo-box-demo"
options={battleRepos}
getOptionLabel={option => option.full_name}
style={{ width: 500 }}
renderInput={params => {
const inputProps = params.inputProps;
inputProps.autoComplete = "off";
return (
<TextField
{...params}
inputProps={inputProps}
label="Combo box"
variant="outlined"
onBlur={event => console.log(event.target.value)}
fullWidth
/>
);
}
}
/>
关于javascript - Material-UI自动完成和TextField触发Google自动完成,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58916722/