我会使用Primeng卡组件
在 module.ts 中,我调用模块。
import { CardModule } from 'primeng/card';
编译时,angular找不到模块
ERROR in /home/haddad/projects/arrr/arrrt/src/app/app.module.ts (9,28): Cannot find module 'primeng/card'.
我使用的是 4.2.4
版本当我更新到primeng的第5版时,我收到此错误
ERROR in Error: Metadata version mismatch for module /home/haddad/projects/node_modules/primeng/components/sidebar/card.d.ts, found version 4, expected 3, resolving symbol AppModule in /home/haddad/projects/ar/arrt/src/app/app.module.ts, resolving symbol AppModule in /home/haddad/projects/ar/arrt/src/app/app.module.ts
我不得不使用角度4。
这是我的 package.json 以获取更多信息:
"dependencies": {
"@angular/animations": "^4.3.6",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": "^4.4.4",
"@angular/http": "^4.4.4",
"@angular/platform-browser": "^4.4.4",
"@angular/platform-browser-dynamic": "^4.4.4",
"@angular/router": "^4.4.4",
"core-js": "^2.4.2",
"font-awesome": "^4.7.0",
"primeng": "^4.2.4",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "1.6.6",
"@angular/compiler-cli": "~4.3.4",
"@angular/language-service": "^4.3.4",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"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": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.3.4"
}
答案 0 :(得分:2)
在互联网上搜索4个小时后,我意识到使用Angular 4的Card组件是不可能的。
在PrimeNg 5.0.2版本中创建的卡组件:card new component
PrimeNg 5.0.0及更高版本与角度4:PrimeNg blog
不兼容Angular 5支持
PrimeNG 5完全支持Angular 5,如果您的项目是在Angular 4上, 要使用的PrimeNG版本为4.x,因为PrimeNG 5不起作用 角度4由于AOT约束。
有必要将Angular版本更新为5。
答案 1 :(得分:0)
要导入卡模块,请尝试以下导入语句:
import { CardModule } from 'primeng/primeng';