html - Html 自动完成输入在 React 中不起作用
问题描述
我创建了一个表单并希望有自动完成功能。因此用户可以选择浏览器建议的电子邮件。我曾经在 Html 中添加autocomplete='on'
到输入或表单,并且它起作用了。但同样的事情在 React 中不起作用。我正在使用 tailwindcss 不确定它是否与它有关。有什么建议么?
<form
autoComplete='on'
>
<input
type='email'
autoComplete='on'
value={claimerEmail}
onChange={(e) => setClaimerEmail(e.target.value)}
className='block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-gray-500 focus:border-gray-500 dark:focus:ring-gray-700 dark:focus:border-gray-700 sm:text-sm dark:text-gray-200 dark:border-gray-800 dark:bg-brand-secondary'
/>
</form>
解决方案
我设法通过像这样添加名称 attr 来解决这个问题。
<form>
<input
type='email'
name='email'
value={claimerEmail}
onChange={(e) => setClaimerEmail(e.target.value)}
className='block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-gray-500 focus:border-gray-500 dark:focus:ring-gray-700 dark:focus:border-gray-700 sm:text-sm dark:text-gray-200 dark:border-gray-800 dark:bg-brand-secondary'
/>
</form>
推荐阅读
- settings - 咖啡因模拟器:找不到文件:WebSearch1.spc.bz2
- javascript - 这段使用 MomentJS 的日期格式化代码有什么问题?
- html - 选择具有角度的特定元素
- python - Python sounddevice 模块输出 Traceback(最后一次调用):
- sql - TERADATA MAX 标准未产生预期的行数
- c# - 使用 SerializationBinder 和 Surrogate 更新数据对象
- php - ORA-01036: oci_bind_by_name() 上的非法变量名称/编号
- javascript - JavaScript If 语句未正确比较变量
- html - 如何使用 CSS 在 n 个字符后中断?
- java - 如何使用 SnakeYaml 对 YAML 中的节点进行排序?