我已经安装:
npm install --save @angular/material @angular/cdk @angular/animations
,并尝试将MatTableDataSource简单地导入到我的组件中,而不使用它:
import {MatTableDataSource} from "@angular/material";
我已经收到以下错误:
ERROR in node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(79,22): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(89,29): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(103,23): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(153,30): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-trap/focus-trap.d.ts(133,30): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/observers/typings/observe-content.d.ts(33,22): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/observers/typings/observe-content.d.ts(67,65): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/overlay/typings/position/connected-position-strategy.d.ts(40,106): error TS2315: Type 'ElementRef' is not generic.
我的版本:
Angular CLI: 1.5.6
Node: 8.9.3
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cdk: 7.3.0
@angular/cli: 1.5.6
@angular/material: 7.3.0
@angular-devkit/build-optimizer: 0.0.40
@angular-devkit/core: 0.0.27
@angular-devkit/schematics: 0.0.50
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.6
@schematics/angular: 0.1.15
@schematics/schematics: 0.0.15
typescript: 2.5.3
webpack: 3.8.1
因为我不知道该如何分析,所以我在这里寻求帮助:-)
答案 0 :(得分:2)
从上面的package.json文件中,您似乎正在使用角度5和角度7 /材质7,这会给您带来麻烦。
将 @angular/material
软件包降级到匹配的版本(或尝试将angular升级到7版本
答案 1 :(得分:0)
我也遇到了同样的问题,我在角上安装了相同版本的材料
npm install --save @angular/material@5.2.5 @angular/cdk@5.2.5