我在 ng build 中收到错误“.form-floating>~label”

Dar*_*lik 7 compiler-errors build angular bootstrap-5

我尝试在我的 Angular 应用程序中运行命令“ng build”,然后我得到:

\n
\xe2\x9c\x94 Browser application bundle generation complete.\n\xe2\x9c\x94 Copying assets complete.\n\xe2\xa0\x8b Generating index html...4 rules skipped due to selector errors:\n  .form-floating>~label -> Did not expect successive traversals.\n  .form-floating>~label -> Did not expect successive traversals.\n  .form-floating>~label -> Did not expect successive traversals.\n  .form-floating>~label -> Did not expect successive traversals.\n\xe2\x9c\x94 Index html generation complete.\n
Run Code Online (Sandbox Code Playgroud)\n

我使用 bootstrap@5.3.1。我在文档中看到了它是什么,但我没有在我的应用程序中使用这些引导类。我有一些输入、标签等,如下所示:

\n
     <form #authForm="ngForm" (ngSubmit)="onSubmit(authForm)" *ngIf="!isLoading">\n            <div class="form-group">\n                <label for="email" class="col-12 mb-3">E-Mail:</label>\n                <input type="email" class="col-12 mb-3" id="email" ngModel name="email" required email />\n            </div>\n            <div class="form-group">\n                <label for="password" class="col-12 mb-3">Password:</label>\n                <input type="password" class="col-12 mb-3" id="password" ngModel name="password" required\n                    minlength="6" />\n            </div>\n            <div *ngIf="error" class="text-center">\n                <p [ngStyle]=" { 'color' : 'red' }">{{ error }}</p>\n            </div>\n            <button class="btn-login" type="submit" [disabled]="!authForm.valid"> {{ isLoginMode ? 'Login' : 'Sign Up'\n                }}</button>\n            <button class="btn-login" type="button" [disabled]="!authForm.valid" (click)="onSwitchMode()">Switch to {{\n                isLoginMode ? 'Sign Up' :\n                'Login' }}</button>\n        </form>\n
Run Code Online (Sandbox Code Playgroud)\n

我不知道我能用这个做什么来解决这个问题。

\n

小智 13

我也一直在处理这个问题,从我收集到的信息来看,这是 Angular 本身的错误。

尝试查看angular.json并替换"optimization": true

"optimization": {
  "scripts": true,
  "styles": {
    "minify": true,
    "inlineCritical": false
  },
  "fonts": true
},
Run Code Online (Sandbox Code Playgroud)

正如这里这里所看到的。如果它是开发版本,您可以将其"optimization": false完全替换。