【问题标题】:How to disable Chrome autocomplete in Redux-Form如何在 Redux-Form 中禁用 Chrome 自动完成功能
【发布时间】:2020-01-27 18:12:16
【问题描述】:

我正在使用 React redux-form 输入,这是我的代码:

return (
        <Field
          key={name}
          component={SurveyField}
          type="text"
          label={label}
          name={name}
          autocomplete="off"
        />
      );

我不希望 chrome 自动完成表单。 我都试过了,但都没有。

autocomplete="off"
autoComplete="off"

我想 Chrome 只是忽略了自动完成。我看过其他 StackOverflow 问题,但没有帮助。

【问题讨论】:

标签: reactjs


【解决方案1】:

我发现将 autocomplete 属性添加到组件回调函数中定义的 &lt;input autoComplete="off"/&gt; 标签而不是依赖于 redux-form &lt;Field /&gt; 标签将此属性传递给 DOM 将在生成的 html 中正确设置此属性和autocomplete="off" 将按预期工作。

【讨论】:

    猜你喜欢
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 2019-03-29
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多