0

我通过密码管理器在 chrome 浏览器中保存了密码,并且我有以下输入字段

<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off">
<input type="password" placeholder="" formControlName="password" #pass autocomplete="off">

每次页面刷新时,浏览器都会自动填充字段

在此处输入图像描述 在此处输入图像描述

我所做的是一个readonlyonfocus输入来禁用自动填充

<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

<input type="password" placeholder="" formControlName="password" #pass autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

现在自动填充会停止每次刷新,这很好。

问题

有没有办法可以隐藏密码管理自动填充字段的焦点(那个黑色的)? 在此处输入图像描述

4

1 回答 1

0
Try adding autocomplete to the form as shown below

<form name="loginForm" autocomplete="off">
<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

<input type="password" placeholder="" formControlName="password" #pass autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>
</form>
于 2021-07-13T07:29:56.813 回答