我安装了:
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因为我不知道该如何分析,所以我在这里寻求帮助:-)
发布于 2019-02-03 15:10:42
从上面的package.json文件看来,您使用的是角5和角/材料7,这将对您造成问题。
要么将@angular/material包降级为匹配版本(或者尝试将角升级到7版本)
发布于 2019-03-18 12:03:50
我也有同样的问题,我安装了相同版本的材料,比如在角度上。
npm install --save @angular/material@5.2.5 @angular/cdk@5.2.5
https://stackoverflow.com/questions/54503696
复制相似问题