首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从“@角/材料”导入"MatTableDataSource“时出错

从“@角/材料”导入"MatTableDataSource“时出错
EN

Stack Overflow用户
提问于 2019-02-03 14:09:48
回答 2查看 1K关注 0票数 2

我安装了:

代码语言:javascript
复制
npm install --save @angular/material @angular/cdk @angular/animations

并试图简单地将MatTableDataSource导入我的组件中,而不使用它:

代码语言:javascript
复制
import {MatTableDataSource} from "@angular/material";

我已经得到以下错误:

代码语言:javascript
复制
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.

我的版本:

代码语言:javascript
复制
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

因为我不知道该如何分析,所以我在这里寻求帮助:-)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-02-03 15:10:42

从上面的package.json文件看来,您使用的是角5和角/材料7,这将对您造成问题。

要么将@angular/material包降级为匹配版本(或者尝试将角升级到7版本)

票数 2
EN

Stack Overflow用户

发布于 2019-03-18 12:03:50

我也有同样的问题,我安装了相同版本的材料,比如在角度上。

npm install --save @angular/material@5.2.5 @angular/cdk@5.2.5

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54503696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档