“ mat-form-field”和“ mat-input-container”有什么区别

Please_Dont_Bully_Me_SO_Lords

我以以下形式创建了该字段:

<mat-form-field class="example-full-width">
  <mat-input-container floatPlaceholder="auto" flex="100">
    <input matInput [(ngModel)]="evento.email" name="email" type="email" placeholder="Email para Contatos" email required [errorStateMatcher]="formMatcher">
  </mat-input-container>
  <mat-hint>Este será o endereço de e-mail oficial do evento.</mat-hint>
  <mat-error *ngIf="formControl.hasError('email') && !formControl.hasError('required')">
    Por favor insira um e-mail com formato válido.
  </mat-error>
  <mat-error *ngIf="formControl.hasError('required')">
    Este campo é <strong>obrigatório.</strong> Não esqueça de preenchê-lo.
  </mat-error>
</mat-form-field>

如果同时使用mat-form-fieldmat-input-container,则会在输入框上方出现2个重复的标签和2行。

我只需要使用其中之一,但是我应该使用哪个呢?为了做出这个决定,我需要知道什么时候最好使用每个决定。有人可以帮忙解释一下吗?我在http://material.angular.io中找不到

G.特兰特

该组件从重命名mat-input-containermat-form-field(我认为是在v2.0.0 beta期间),但是v5.x仍支持旧的选择器。在v6.x中,mat-input-container不再受支持。因此,您应该使用新名称mat-form-field

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

用于mat-input和mat-form-field的CSS问题

UMat和OpenCV中的Mat有什么区别?

OpenCV 中的 Mat 和 SparseMat 有什么区别?

为什么 mat-form-field 没有出现?

与mat-form-field中的matSuffix mat-checkbox交互

mat-list-item 重叠中的 mat-form-field

如何调整mat-form-field mat-chip的大小?

mat-form-field必须包含MatFormFieldControl

如何从Mat-form-field中删除Mat-form-field-wrapper?

解决错误后,mat-form-field不会删除mat-form-field-invalid类

当通过 numpy 矩阵进行索引时, mat[:3,1:2] 和 mat[:3,1] 之间有什么区别?

mat-toolbar,mat-sidenav和mat-sidenav-container未知

普通引导文本字段样式和 mat-text 字段样式之间有什么区别

为什么在此FormArray中无法编辑mat-form-field?

带有 mat-card 和 mat-card-actions/mat-card-footer 的 mat-grid-list

角度指令-ElementRef-无法从mat-form-field中选择mat-select

将拖放添加到 mat-form-field 中的 mat-chip 列表

如何动态地将mat-error添加到mat-input-field?

Mat-form-field 在不同的浏览器中具有不同的高度

mat-form-field 输入与使用 CSS 定义的页面具有相同的背景

“ mat-form-field”不是一个已知元素-Angular 4和Angular Material 2

正确的方法来填充和删除mat-form-field的边距

是否可以将当前日期和时间放在 mat-form-field 中?

在触摸控件之前显示mat-form-field错误消息

如何基于值禁用角度的mat-form-field?

mat-form-field始终显示所需的红色?

在mat-form-field中更改边框颜色

是否可以调整 mat-form-field-outline 的厚度?

mat-form-field必须包含MatFormFieldControl并且已经导入