我有下面的 react 形式,我需要实现“autoComplete="on",这样下次如果用户想要输入相同的值,它应该被建议为自动完成。下面是我的代码
<form className={classes.container} noValidate>
<Grid container item xs={12} alignItems="center">
<TextField
id="outlined-bare"
className={classes.textField1}
defaultValue=""
margin="normal"
variant="outlined"
autoComplete="on"
InputProps={{ style: { height: 40 } }}
onChange={(e) => handleChange(e, 'Name')}
/>
</Grid>
正在渲染的组件是 Chrome 浏览器。这里有什么问题或缺失?
最佳答案
这是下面的代码。您可以在表单标签中添加 autoComplete="on"
。
<form className={classes.container} noValidate autoComplete="on">
<Grid container item xs={12} alignItems="center">
<TextField
id="outlined-bare"
className={classes.textField1}
defaultValue=""
margin="normal"
variant="outlined"
autoComplete="on"
InputProps={{ style: { height: 40 } }}
onChange={(e) => handleChange(e, 'Name')}
/>
</Grid>
</form>
关于html - autoComplete "on"在 ReactJs 表单中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58377393/