AOT构建时不会浮动角材料标签

问题描述 投票:0回答:1

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

My labels just stay in the way instead of floating up as they do with non AOT builds`

<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个回答
0
投票

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

[看到这解决了问题之后,我对该特定标志进行了更多研究,并发现Angular CLI已有相当长的一段时间了,这里记录-> https://github.com/angular/angular-cli/issues/8577

© www.soinside.com 2019 - 2024. All rights reserved.