原文链接:https://blog.csdn.net/codezha/article/details/90752488

问题:在登录页面上点击修改密码后,input框会自动填充当前登录用户名。

原因:浏览器对于用户保存过的户名和密码有自动填充功能,关掉自动填充功能即可。

方法:设置autocomplete为off,适用于普通文本框;设置autocomplete为new-password,适用于密码输入框
//用户名
<input type="text" autoComplete="off"/>
//密码
<input type="password" autoComplete="new-password"/>

需要注意的是在JSX中使用时,需注意大小写问题,必须为autoComplete,否则无效。

//用户名
<input type="text" style="position:absolute;z-index:-999"/>
或者
<input type="text" style="display:none"/>
//密码
<input type="password" style="position:absolute;z-index:-999"/>
或者
<input type="password" style="display:none"/>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-02-10
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案