我正在尝试将弹性布局添加到角度应用程序中,但是当我这样做并尝试使用它时,应用程序会崩溃。我已经安装了
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.
而这样的例子不胜枚举。我是否有某些版本不匹配的情况?
这是因为您使用的是 Angular 8,但该库需要 Angular 9。在您的 package.json 中使用此版本:"@angular/flex-layout": "^8.0.0-beta.27"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)