【发布时间】:2018-12-26 16:54:34
【问题描述】:
我刚刚安装了材料:
npm install --save @angular/material @angular/cdk @angular/animations
导入模块:
import { MatTabsModule } from '@angular/material/tabs';
这个question's 回答说这是因为版本与动画不匹配。我不确定要更新什么。 @angular/material 的版本比 angular 的依赖项更新。该问题的答案是安装较早版本的材料,但我只想使用最新版本。
我尝试安装旧版本的@angular/material,但还是没有用。
npm ERR! notarget No matching version found for @angular/material@6.1.10
错误:
core.es5.js:1739 Uncaught TypeError: Object(...) is not a function
at Module../node_modules/@angular/material/esm5/core.es5.js (core.es5.js:1739)
at __webpack_require__ (bootstrap:78)
at Module../node_modules/@angular/material/esm5/tabs.es5.js (tabs.es5.js:1)
package.json
{
//...
"dependencies": {
"@angular/animations": "^6.1.10",
"@angular/cdk": "^6.4.7",
"@angular/common": "^6.1.10",
"@angular/compiler": "^6.1.10",
"@angular/core": "^6.1.10",
"@angular/forms": "^6.1.10",
"@angular/http": "^6.1.10",
"@angular/material": "^7.2.0",
"@angular/platform-browser": "^6.1.10",
"@angular/platform-browser-dynamic": "^6.1.10",
"@angular/router": "^6.1.10",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"rxjs": "~6.2.0",
"zone.js": "~0.8.26"
},
更新:
我更新到 Angular 7,它现在可以工作了。
"dependencies": {
"@angular/animations": "^7.1.4",
"@angular/cdk": "^7.2.0",
"@angular/common": "^7.1.4",
"@angular/compiler": "^7.1.4",
"@angular/core": "^7.1.4",
"@angular/forms": "^7.1.4",
"@angular/http": "^7.1.4",
"@angular/material": "^7.2.0",
"@angular/platform-browser": "^7.1.4",
"@angular/platform-browser-dynamic": "^7.1.4",
"@angular/router": "^7.1.4",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
【问题讨论】:
-
当然,没有
@angular/material@6.1.10,在6.1.0之后,6.2.0直接在angular/material更新日志中.. 试试npm i @angular/material@6.1.*