原文鏈接: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"/>