jak dołączyć układ Flex


9

Próbuję dodać układ Flex do aplikacji kątowej, ale kiedy to zrobię i spróbuję go użyć, aplikacja się zepsuje. Zainstalowałem

npm i @angular/flex-layout @angular/cdk

następnie importowane do app.module.ts

import { FlexLayoutModule } from '@angular/flex-layout';

import [ FlexLayoutModule ]

Zaktualizowałem również maszynopis do najnowszej wersji

npm i typescript@latest

Ale gdy aplikacja próbuje się skompilować, pojawiają się różnego rodzaju błędy:

ERROR in node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:24:19 - error TS1086: An accessor cannot be declared in an ambient context.

24     protected get parentElement(): HTMLElement | null;
                 ~~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19 - error TS1086: An accessor cannot be declared in an ambient context.

26     protected get nativeElement(): HTMLElement;
                 ~~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9 - error TS1086: An accessor cannot be declared in an ambient context.

28     get activatedValue(): string;
       ~~~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9 - error TS1086: An accessor cannot be declared in an ambient context.

29     set activatedValue(value: string);
       ~~~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9 - error TS1086: An accessor cannot be declared in an ambient context.

20     get overlappings(): BreakPoint[];
       ~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:24:9 - error TS1086: An accessor cannot be declared in an ambient context.

i lista jest długa. Czy mam coś niezgodnego z wersją?

Dzięki.....


lub może być wersja na maszynie>
— Prashant Pimpale

Odpowiedzi:


7

Spróbuj dodać tslib w zależnościach

npm install --save tslib

Edytować

Jeśli używasz Angular v8, użyj v8 do flex-layout, ponieważ v9 potrzebuje Angular v9.


Bez zmiany. Te same błędy jak poprzednio.
— cpeddie

3
Ktoś już podniósł problem z błędem TS1086. Zrabuj z niego i jego rozwiązanie . Odpowiedź brzmiv9 requires Angular v9 and more importantly TypeScript v3.7. Please use the v8 release of Flex Layout.
— Ratnadeep Bhattacharyya

To było to. Niewłaściwa wersja Flex Layout.
— cpeddie

23

To dlatego, że korzystasz z Angulara 8, ale biblioteka wymaga Angulara 9. W pakiecie.json użyj tej wersji: "@angular/flex-layout": "^8.0.0-beta.27"


Dzięki, to działa dla mnie!
— user3856842
Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.