gpt4 book ai didi

无法找到 Angular Material MatTableDataSource

转载 作者:行者123 更新时间:2023-12-02 04:08:04 30 4
gpt4 key购买 nike

我正在尝试使用 Angular Material Table 创建一个表,在示例中始终存在导入:

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

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

我有什么遗漏的吗?

这是 package.json 版本:

"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 中的新功能。我将 Angular 4 更新为 Angular 5,并将 Angular Material 更新为 5.0.0-rc0。 (引用:https://github.com/angular/material2/releases)

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

{
"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": {}
}

关于无法找到 Angular Material MatTableDataSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47390727/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com