【问题标题】:Html Autocomplete Input not working in ReactHtml 自动完成输入在 React 中不起作用
【发布时间】:2021-10-23 13:27:00
【问题描述】:

我已经创建了一个表单并且想要自动完成。因此用户可以选择浏览器建议的电子邮件。我曾经将autocomplete='on' 添加到 Html 中的输入或表单中,它起作用了。但同样的事情在 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>

【问题讨论】:

    标签: html reactjs forms tailwind-css


    【解决方案1】:

    我设法通过像这样添加名称 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-19
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 2021-10-02
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      相关资源
      最近更新 更多