【问题标题】:FlexLayoutModule not working with Angular 11FlexLayoutModule 不适用于 Angular 11
【发布时间】:2021-01-02 08:13:32
【问题描述】:

我今天更新到第 11 版。我的包 json 在下面。 FlexLayoutModule 不再使用指令参与和格式化 div。似乎根本没有发生任何事情,但我没有收到任何错误消息。这是我的 package.json 和 app 模块。

我确实在 github 上发现了一些闲聊,表明当 Angular 11 发布时,Flex 的第 10 版无法工作。讨论似乎刚刚结束,没有任何结论。任何帮助都很棒。

{
  "name": "mak-clean",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^11.0.3",
    "@angular/cdk": "~8.2.3",
    "@angular/common": "~11.0.3",
    "@angular/compiler": "~11.0.3",
    "@angular/core": "~11.0.3",
    "@angular/fire": "^6.1.4",
    "@angular/flex-layout": "^11.0.0-beta.33",
    "@angular/forms": "^11.0.3",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "~11.0.3",
    "@angular/platform-browser-dynamic": "~11.0.3",
    "@angular/router": "~11.0.3",
    "@material-ui/core": "^4.11.2",
    "@ngrx/data": "^10.1.0",
    "@ngrx/effects": "^10.1.0",
    "@ngrx/entity": "^10.1.0",
    "@ngrx/router-store": "^10.1.0",
    "@ngrx/store": "^10.1.0",
    "@ngrx/store-devtools": "^10.1.0",
    "firebase": "^8.1.2",
    "jasmine": "^3.6.3",
    "rxjs": "^6.6.3",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.3",
    "@angular/cli": "~11.0.3",
    "@angular/compiler-cli": "~11.0.3",
    "@angular/language-service": "~11.0.3",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.5"
  }
}

我尝试将 Flex 模块注入我的功能模块,但这没有帮助。这是我的应用程序模块,显示它已注入。

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { HttpClientModule } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';


// Mak Studio Modules
import { LoginModule } from './main/Common/login/login.module';
import { ProfileModule } from './main/profile/profile.module';
import { NavbarModule } from './main/Shared/navbar/navbar.module';


// Google Firebase
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from "@angular/fire/auth";
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { environment } from '../environments/environment';


// NGRX Items
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { metaReducers, reducers } from '../app/main/store/reducers';
import { EntityDataModule } from '@ngrx/data';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { RouterState, StoreRouterConnectingModule } from '@ngrx/router-store';


@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    // Standard modules
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    FlexLayoutModule,
    HttpClientModule,

    // Mak modules
    LoginModule,
    NavbarModule,
    ProfileModule,


    // Firestore Auth Modules
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,
    AngularFirestoreModule,
    AngularFireStorageModule,


    // NGRX items
    StoreModule.forRoot(reducers, {
      metaReducers,
      runtimeChecks : {
        strictStateImmutability: true,
        strictActionImmutability: true,
        strictActionSerializability: true,
        strictStateSerializability:true
      }
    }),
    StoreDevtoolsModule.instrument({maxAge: 25, logOnly: environment.production}),
    EffectsModule.forRoot([]),
    EntityDataModule.forRoot({}),
    StoreRouterConnectingModule.forRoot({
      stateKey: 'router',
      routerState: RouterState.Minimal
    }),
    StoreModule.forRoot({}, {}),
    StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: environment.production })


  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

【问题讨论】:

  • 执行npm i 后,您的终端是否收到任何警告?
  • 我做到了,但我回滚到版本 10 并解决了这些问题。 flex 仍然无法正常工作。

标签: angular flexbox


【解决方案1】:

您必须一次更新所有依赖项。请尝试,npm update @angular/material @angular/flex-layout @angular/cdk

【讨论】:

    【解决方案2】:

    尝试按照 angular 11 更新 @angular/cdk。正如 https://github.com/angular/flex-layout/blob/master/CHANGELOG.md#1100-beta33-2020-11-12 所说的使用 @angular/cdk v11。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-07
      • 2021-07-13
      • 2021-05-19
      • 2021-07-25
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多