找不到角材料MatTableDataSource

找不到角材料MatTableDataSource

本文介绍了找不到角材料MatTableDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Angular Material Table 创建一个表例子中总是有导入:

I'm trying to create a table using Angular Material Table, in the examples there is always the import:

import {MatTableDataSource} from '@angular/material';

我正在尝试执行相同的操作,但出现错误:模块' ../node_modules/@ angular/material/material '没有导出的成员 MatTableDataSource .

I'm trying to do the same but I'm getting an error: "Module '../node_modules/@angular/material/material' has no exported member MatTableDataSource.

有什么我想念的吗?

这是package.json版本:

Here's the package.json versions:

"dependencies": {
 "@angular/animations": "^4.4.6",
 "@angular/cdk": "^2.0.0-beta.12",
 "@angular/common": "^4.2.4",
 "@angular/compiler": "^4.2.4",
 "@angular/core": "^4.2.4",
 "@angular/forms": "^4.2.4",
 "@angular/http": "^4.2.4",
 "@angular/material": "^2.0.0-beta.12",
 "@angular/platform-browser": "^4.2.4",
 "@angular/platform-browser-dynamic": "^4.2.4",
 "@angular/router": "^4.2.4",
 "bootstrap": "^3.3.7",
 "core-js": "^2.4.1",
 "pdfmake": "^0.1.33",
 "rxjs": "^5.4.2",
 "zone.js": "^0.8.14"
},
"devDependencies": {
 "@angular/cli": "1.4.9",
 "@angular/compiler-cli": "^4.2.4",
 "@angular/language-service": "^4.2.4",
 "@types/jasmine": "~2.5.53",
 "@types/jasminewd2": "~2.0.2",
 "@types/node": "~6.0.60",
 "codelyzer": "~3.2.0",
 "jasmine-core": "~2.6.2",
 "jasmine-spec-reporter": "~4.1.0",
 "karma": "~1.7.0",
 "karma-chrome-launcher": "~2.1.1",
 "karma-cli": "~1.0.1",
 "karma-coverage-istanbul-reporter": "^1.2.1",
 "karma-jasmine": "~1.1.0",
 "karma-jasmine-html-reporter": "^0.2.2",
 "protractor": "~5.1.2",
 "ts-node": "~3.2.0",
 "tslint": "~5.7.0",
 "typescript": "~2.3.3"
}

推荐答案

我遇到了同样的问题.事实证明,MatTableDataSource是Angular Material 5.0.0-rc0中的新功能.我将角度4更新为角度5,并将角度材质更新为5.0.0-rc0. (参考: https://github.com/angular/material2/releases )

I was having the same problem. Turns out, MatTableDataSource is new feature in Angular Material 5.0.0-rc0.I updated angular 4 to angular 5 and updated angular material to 5.0.0-rc0. (ref: https://github.com/angular/material2/releases)

如果有帮助,这是我的package.json文件.

If it helps, here is my package.json file.

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "^5.0.2",
    "@angular/cdk": "^5.0.0-rc0",
    "@angular/common": "^5.0.2",
    "@angular/compiler": "^5.0.2",
    "@angular/core": "^5.0.2",
    "@angular/forms": "^5.0.2",
    "@angular/http": "^5.0.2",
    "@angular/material": "^5.0.0-rc0",
    "@angular/platform-browser": "^5.0.2",
    "@angular/platform-browser-dynamic": "^5.0.2",
    "@angular/router": "^5.0.2",
    "angular-in-memory-web-api": "~0.5.1",
    "angular-material": "^1.1.5",
    "core-js": "^2.5.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.5.2",
    "systemjs": "0.20.19",
    "zone.js": "^0.8.18"
  },
  "devDependencies": {
    "concurrently": "^3.5.0",
    "lite-server": "^2.3.0",
    "typescript": "~2.6.0",
    "canonical-path": "0.0.2",
    "tslint": "^5.8.0",
    "lodash": "^4.17.4",
    "jasmine-core": "~2.8.0",
    "karma": "^1.7.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.2.0",
    "rimraf": "^2.6.2",
    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36"
  },
  "repository": {}
}

这篇关于找不到角材料MatTableDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:23