【问题标题】:Angular Material Label Won't Float with AOT BuildAngular 材质标签不会随 AOT 构建浮动
【发布时间】:2020-03-31 20:26:17
【问题描述】:

一段时间以来,我一直在寻找其他人是否遇到此错误,但无济于事。我最近将我的网站升级到 Angular 8 并开始使用 Angular CLI 而不是 webpack。我终于用 --aot 标志运行了一个生产版本,发现一些奇怪的行为,Angular Material Labels 不像往常那样浮动。我的浏览器中也没有任何控制台错误。

`

<mat-form-field appearance="outline" floatLabel="always">
    <mat-label>{{ label || 'User' }}</mat-label>
    <input matInput spellcheck="false" [formControl]="userInputControl">
    <mat-icon matPrefix style="cursor: pointer; margin-right: 10px;">search</mat-icon>
    <mat-icon matSuffix style="cursor: pointer;" (click)="updateUserListSettings()">person</mat-icon>
    <mat-hint>Search using User ID, Name, or Email Address</mat-hint>
</mat-form-field>
<mat-form-field class="te-form-225" appearance="outline">
    <mat-label>Role Class</mat-label>
    <mat-select [(ngModel)]="filterRoleClass" (selectionChange)="filterRoles()">
        <mat-option *ngFor="let rc of roleClasses" [value]="rc">{{ rc | titleCase }}</mat-option>
    </mat-select>
</mat-form-field>

Angular CLI: 8.3.20
Node: 12.13.1
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.10
@angular-devkit/build-angular     0.803.10
@angular-devkit/build-optimizer   0.803.10
@angular-devkit/build-webpack     0.803.10
@angular-devkit/core              8.3.10
@angular-devkit/schematics        8.3.20
@angular/cdk                      8.2.3
@angular/cli                      8.3.20
@angular/material                 8.2.3
@ngtools/webpack                  8.3.10
@schematics/angular               8.3.20
@schematics/update                0.803.20
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.41.1

【问题讨论】:

    标签: angular angular8 angular-cli-v8 angular-material-8


    【解决方案1】:

    我最终通过将 build -> options -> extractCss 的 angular.json 文件设置更改为 false 来解决我自己的问题。

    在看到这个解决问题后,我对该特定标志进行了更多研究,发现它在 Angular CLI 中已经存在很长一段时间了,记录在这里 -> https://github.com/angular/angular-cli/issues/8577

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-12
      • 2017-06-22
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多