Angular Material 2 Form不显示

问题描述 投票:-4回答:1

我正在尝试添加材料2网站中描述的表单和输入。表单不显示,但是当我单击表单输入时,它会显示。

附加信息(更新):

我正在使用自定义主题。

$customTheme: mat-dark-theme($primary, $accent, $warn); 

但当我将其更改为更轻的主题时,表单元素就会显示出来。

$customTheme: mat-light-theme($primary, $accent, $warn);

我想这与background和currentColor有关。

angular material-design angular-material angular2-forms angular-material2
1个回答
1
投票

我能搞清楚。

使用深色主题时,预期表单的背景为深色而不是白色。

我添加了一个带有浅背景主题的secondaryTheme并在表单中使用它并解决了这个问题。

$mainTheme: mat-dark-theme($primary, $accent, $warn);

$secondaryTheme : mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($mainTheme);

.secondaryTheme {
    @include angular-material-theme($secondaryTheme);
}

<div class="secondaryTheme">

  <mat-form-field>
  <input matInput placeholder="Input">
  </mat-form-field>

  <mat-form-field>
  <textarea matInput placeholder="Textarea"></textarea>
  </mat-form-field>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.