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

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

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

方法:设置autocompleteoff,适用于普通文本框;设置autocompletenew-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"/>

 

posted on 2021-04-25 17:57  多年小白  阅读(1296)  评论(0编辑  收藏  举报