【问题标题】:angular 4 reactive forms with material 2, disabling autocomplete带有材料 2 的 Angular 4 反应形式,禁用自动完成
【发布时间】:2017-12-28 15:53:51
【问题描述】:

我正在使用 angular cli、angular 4 和 angular material 2。我需要禁用 chrome 自动完成功能,但我无法这样做。

我已经搜索并发现我需要在表单和输入中添加 autocomplete=off 或 autocomplete=false 。我还通过添加 type="search" 找到了解决方法。它们似乎都不起作用。

材料或角度是否会覆盖此说明?

我正在使用响应式表单!

有什么建议吗?

提前感谢您的帮助

【问题讨论】:

  • 你找到解决这个问题的方法了吗?
  • 不,很遗憾还没有!
  • 你找到解决这个问题的方法了吗?
  • 不,很遗憾,不!但这不再是问题
  • 现在,您找到解决方案了吗?

标签: angular4-forms


【解决方案1】:

Chrome 不再支持 autocomplete="off"(Chrome 在 34.0 中停止支持此功能)。相反,请改用 autocomplete="new-password"。 你可以在here上查看 Mozilla 的文档

来自文档:

因此,许多现代浏览器不支持登录字段的 autocomplete="off":

如果网站为用户名和密码输入设置了 autocomplete="off" 字段,则浏览器仍会提供记住此登录信息,并且 如果用户同意,浏览器将在下一个自动填充这些字段 用户访问页面的时间。这是 Firefox 中的行为(因为 版本 38)、Google Chrome (自 34) 和 Internet Explorer (自 版本 11)。

如果作者想阻止密码字段的自动填充 在用户管理页面中,用户可以为其指定新密码 除了自己之外的其他人, autocomplete="new-password" 应该是 已指定,尽管尚未全部实施对此的支持 浏览器。

例子:

<mat-form-field *ngIf="filter.editorType==='text'">
    <input matInput autocomplete="new-password"
    [formControlName]="filter.id" 
    [placeholder]="filter.name" 
    (keyup.enter)="onApplyFiltersKeyboard()">
</mat-form-field>

【讨论】:

    【解决方案2】:

    只需将属性autocomplete 分配给其他东西

    【讨论】:

      猜你喜欢
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      • 2017-07-14
      • 1970-01-01
      相关资源
      最近更新 更多