我是角度和材料设计的新手。来自iOS开发,这对我来说很难。我在我的公司有项目,我正在为Angular寻找Material Design版本2.0.0-beta.7的文档。我知道有很好的网站here包含每个组件的文档,但我注意到这是针对版本2.0.0-beta.12的,例如所有前缀Md都更改为Mat。我试图将Md更新到版本2.0.0-beta.12但是我的项目中出现了类似的问题:
npm WARN @angular/cdk@2.0.0-beta.12 requires a peer of @angular/core@~4.4.4 but none was installed.
npm WARN @angular/cdk@2.0.0-beta.12 requires a peer of @angular/common@~4.4.4 but none was installed.
npm WARN @angular/material@2.0.0-beta.12 requires a peer of @angular/core@~4.4.4 but none was installed.
npm WARN @angular/material@2.0.0-beta.12 requires a peer of @angular/common@~4.4.4 but none was installed.
在这一刻我停止了因为我害怕,因为我没有足够的经验来处理角度世界中的这种问题而我感到遗憾的是我错过了一些东西。我不想更新所有@ angular / core等因为在当前项目中一切正常运行。我们只需要使用Material Design添加更多组件,因为我正在学习它,我需要我的版本的文档,因为beta.12与我注意到的非常不同。所以我回到版本beta.7所以项目再次运行,但嘿。这个版本的文档在哪里?如何找到它?
这是我的package.json deps和devDeps:
"dependencies": {
"@angular/animations": "4.2.3",
"@angular/common": "4.2.3",
"@angular/compiler": "4.2.3",
"@angular/core": "4.2.3",
"@angular/flex-layout": "2.0.0-beta.8",
"@angular/forms": "4.2.3",
"@angular/http": "4.2.3",
"@angular/material": "^2.0.0-beta.7",
"@angular/platform-browser": "4.2.3",
"@angular/platform-browser-dynamic": "4.2.3",
"@angular/router": "4.2.3",
"ag-grid": "^13.3.1",
"ag-grid-angular": "^13.3.0",
"core-js": "2.4.1",
"hammerjs": "2.0.8",
"rxjs": "5.4.1",
"zone.js": "0.8.12"
},
"devDependencies": {
"@angular/cli": "1.1.3",
"@angular/compiler-cli": "4.2.3",
"@types/jasmine": "2.5.45",
"@types/node": "6.0.78",
"@types/hammerjs": "2.0.34",
"codelyzer": "3.0.1",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"karma-coverage-istanbul-reporter": "1.3.0",
"protractor": "5.1.2",
"ts-node": "3.0.6",
"tslint": "5.3.2",
"typescript": "2.3.4"
}
答案 0 :(得分:1)
自Angular Material 2版本beta 11以来,该库现在需要Angular 4.4.3或更高版本,因此您应该更新到最新版本的angular来解决问题。这是一个很好的网站,可让您选择当前使用的版本以及要升级的版本,并为您提供所有必需的步骤:
答案 1 :(得分:0)
如果你仔细观察package.json,你会发现必须将@ angular / core从4.2.3更新到~4.4.4。这同样适用于@ angular / common
试试这个
在Linux / Mac上:
npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save
在Windows上:
npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save