代码之家  ›  专栏  ›  技术社区  ›  mcfly soft

从“@angular/material”导入“MatTableDataSource”时出错

  •  0
  • mcfly soft  · 技术社区  · 7 年前

    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
    

    因为我不知道如何分析这一点,我在这里请求帮助:-)

    1 回复  |  直到 7 年前
        1
  •  2
  •   Sajeetharan    7 年前

    要么降级 @angular/material

        2
  •  0
  •   Samet ÇELİKBIÇAK    7 年前

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

    推荐文章