플렉스 레이아웃을 어떻게 포함합니까


10

각도 앱에 flex-layout을 추가하려고하지만 사용하려고하면 앱이 중단됩니다. 설치했습니다

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

그런 다음 app.module.ts에서 가져옵니다.

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

import [ FlexLayoutModule ]

나는 또한 typescript를 최신으로 업그레이드했습니다

npm i typescript@latest

그러나 앱이 컴파일하려고하면 모든 종류의 오류가 발생합니다.

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.

그리고 목록은 계속됩니다. 버전이 일치하지 않습니까?

감사.....


또는 타이프 스크립트 버전 일 수 있음>
— Prashant Pimpale

답변:


7

의존성에 tslib를 추가하십시오

npm install --save tslib

편집하다

Angular v8을 사용하는 경우 flex-layout에 v8을 사용하면 v9에 Angular v9가 필요합니다.


변경 없음. 이전과 같은 오류.
— cpeddie

3
누군가 이미 TS1086 오류 문제를 제기합니다. 그것과 그것의 해결책을 약탈하십시오 . 답변은 다음과 같습니다v9 requires Angular v9 and more importantly TypeScript v3.7. Please use the v8 release of Flex Layout.
— Ratnadeep Bhattacharyya

그거였다. Flex Layout의 버전이 잘못되었습니다.
— cpeddie

24

Angular 8에 있지만 라이브러리에는 Angular 9가 필요하기 때문입니다. package.json에서이 버전을 사용하십시오. "@angular/flex-layout": "^8.0.0-beta.27"


고마워, 그것은 나를 위해 작동합니다!
— user3856842
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.