【问题标题】:autocomplete="current-password" in React not showing fill formReact 中的 autocomplete="current-password" 未显示填写表单
【发布时间】:2019-04-06 02:47:04
【问题描述】:

我在使用autocomplete="current-password" 时遇到问题,其中表单未显示当前密码。密码保存在 Chrome 中。 input 包裹在 form 中。有人对autocomplete="current-password" 不为他们工作有疑问吗?

这是我对 React 的输入:

<input
  type={this.state.visible ? `text` : `password`}
  onChange={(e) => this.props.onChange('password', e.target.value)}
  autoComplete="current-password"
  placeholder="password"
 />

我没有看到任何关于这不起作用或有人提到这不起作用。

注意:autoComplete 在 React 中必须以这种方式拼写,因为 react 无法将属性识别为 autocomplete,但在 DOM 上呈现为 autocomplete

这是元素在DOM 上的呈现方式:

<form class="sign-in">
  <div class="input-group">
    <label>Email</label>
    <input type="email" placeholder="achroma@gmail.com" autocomplete="username" name="email" value="">
  </div>
  <div class="input-group">
    <div class="password-top">
      <label>Password</label>
      <span class="password-toggle">show password</span>
    </div>
  <input type="password" autocomplete="current-password" placeholder="password">
  <span class="forgot-password">Forgot Password?</span>
  </div>
</form>

【问题讨论】:

  • 你周围有 autocomplete="username" 吗?以父形式可能是?
  • @SimDim 看一下我刚刚添加的DOM的渲染
  • 你在本地主机上试试这个吗?

标签: html reactjs autocomplete


【解决方案1】:

生成的 HTML 至少缺少 name="password"

此外,目前 Chrome 不建议为 localhost 自动填充密码。我不得不在 Chrome 设置中重新启用自动登录,因为我的 Chrome 没有建议在任何网站上自动填充密码。希望对您有所帮助。

我已经在一个干净的 react 项目中测试了你的代码,刚刚在密码输入中添加了name="password",并使用了我机器的代理。它似乎在 Chrome 中工作。

【讨论】:

    猜你喜欢
    • 2022-09-29
    • 2021-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-29
    相关资源
    最近更新 更多