Angular 如何包含flex布局?
我试图将flex布局添加到angular应用程序中,但当我添加并尝试使用它时,应用程序会中断。我已经安装了Angular 如何包含flex布局?,angular,angular-flex-layout,Angular,Angular Flex Layout,我试图将flex布局添加到angular应用程序中,但当我添加并尝试使用它时,应用程序会中断。我已经安装了 npm i @angular/flex-layout @angular/cdk 然后在app.module.ts中导入 import { FlexLayoutModule } from '@angular/flex-layout'; import [ FlexLayoutModule ] 我还将typescript升级到最新版本 npm i typescript@latest 但当
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.
这一清单还在继续。我是否有版本不匹配的内容?尝试在依赖项中添加tslib
npm install --save tslib
编辑
如果您使用的是Angular v8,那么将v8用于flex布局,因为v9需要Angular v9。这是因为您使用Angular 8,但库需要Angular 9。在package.json中使用以下版本:
“@angular/flex layout”:“^8.0.0-beta.27”
或者可能是typescript version>这是否回答了您的问题?已有人提出TS1086错误的问题。答案是
v9需要角度v9,更重要的是TypeScript v3.7。请使用Flex Layout的v8版本。
就是这样。Flex布局的错误版本。
"@angular/flex-layout": "^8.0.0-beta.27"
npm install
"compilerOptions": {
"skipLibCheck":true
}