繁体   English   中英

如何在角度表单字段上禁用浏览器自动完成功能?

[英]How to disable browser autocomplete on angular form field?

我有一个登录页面,我想停止自动完成并自动填写我的表单页面。

通过使用 autocomplete="off" 自动填充停止。 但是当我单击输入字段(密码或用户名字段)时,自动完成仍然加载。 如何停止这个自动完成?

我尝试了以下方法, autocomplete="off", autocomplete="false", autocomplete="new-password" 但它还是来了。

我的示例代码:

<form #f="ngForm" autocomplete="off">
  <mat-form-field floatLabel="auto">
    <mat-label>User name</mat-label>
    <mat-icon matPrefix>person</mat-icon>
    <input matInput 
           tabindex="1" 
           #username="ngModel"
           [(ngModel)]="userName" 
           required 
           name="username"
           maxlength="100" 
           autocomplete="off" 
           role="presentation">
  </mat-form-field>
  <mat-form-field floatLabel="auto">
    <mat-label>Password</mat-label>
    <mat-icon matPrefix>lock</mat-icon>
    <input matInput 
           tabindex="2" 
           [(ngModel)]="password" 
           required 
           name="password" 
           #pass="ngModel" 
           type="password" 
           maxlength="100"
           autocomplete="new-password" 
           role="presentation">
  </mat-form-field>
</form>

谷歌浏览器版本:76.0.3809.100 版(官方版本)(64 位)

在自动完成和随机名称上添加“anystring”以进行标记。

autocomplete="anyrandomstring" name="test"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM