我是角度和离子的新手。我正在使用
“@ angular / forms”:“^ 4.3.1”
“离子角”:“^ 3.5.3”
我已经安装了ionic-angular和@ angular / forms包。我收到以下错误消息。
Unhandled Promise rejection: Template parse errors:
'ion-card-header' is not a known element:
1. If 'ion-card-header' is an Angular component, then verify that it is part of this module.
2. If 'ion-card-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-card>
[ERROR ->]<ion-card-header>
Header
</ion-card-header>
任何想法如何解决将非常感激。
我已经放入了它并且它也开始抱怨。请看下面的图片。
$ ionic info
[WARN] You are not in an Ionic project directory. Project context may be
missing.
global packages:
@ionic/cli-utils : 1.5.0
Ionic CLI : 3.5.0
System:
Node : v6.11.1
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 3.10.10
我基本上正在创建一个库,我将需要所有组件,然后我将在一个单独的项目中使用这些组件。
"dependencies": {
"@angular/forms": "^4.3.1",
"ionic-angular": "^3.5.3",
"ionicons": "^3.0.0"
},
"peerDependencies": {
"@angular/common": "^4.0.0",
"@angular/core": "^4.0.0"
},
"devDependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@compodoc/compodoc": "^1.0.0-beta.9",
"@types/jasmine": "^2.5.47",
"@types/karma": "^0.13.35",
"@types/node": "^7.0.18",
"@types/webpack": "^2.2.15",
"@types/webpack-env": "^1.13.0",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^3.1.3",
"codecov": "^2.2.0",
"codelyzer": "^3.0.1",
"concurrently": "^3.4.0",
"css-loader": "^0.28.1",
"gh-pages": "^1.0.0",
"gulp": "^3.9.1",
"gulp-inline-ng2-template": "^4.0.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jasmine-core": "^2.6.1",
"json-loader": "^0.5.4",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.3",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3",
"node-sass": "^4.5.2",
"raw-loader": "^0.5.1",
"rimraf": "2.6.1",
"rxjs": "^5.3.1",
"sass-loader": "^6.0.5",
"source-map-explorer": "^1.3.3",
"to-string-loader": "^1.1.5",
"ts-node": "^3.0.4",
"tslint": "^5.2.0",
"typescript": "2.4.0",
"webpack": "^2.5.1",
"webpack-angular-externals": "^1.0.2",
"webpack-rxjs-externals": "^1.0.0",
"zone.js": "^0.8.10"
}
我是离子和棱角分明的新手。
答案 0 :(得分:1)
根据您的上述代码,您错过了关闭离子卡。
<ion-card>
<ion-card-header>
</ion-card-header>
</ion-card>
更新1:
我在您的代码中看到的问题数量
选择器应与 .ts 文件
具有相同的名称@Component({
selector: 'ionic-test.component',
templateUrl: 'ionic-test.component.html'
})
确保您的组件标记位于 ion-content 中。例如,
<ion-content>
<ion-grid>
<ion-row> </ion-row>
<ion-row> </ion-row>
</ion-grid>
<ion-card>
<ion-card-header>
</ion-card-header>
</ion-card>
</ion-content>
尝试将.scss移动到 ion-content 并将.scss名称更改为其他名称。
<ion-content class="ionic-test.component.styles">
</ion-content>
还要确保 .ts,.html,.scss 文件位于同一根文件夹中
更新2:
根据您最近的编辑可能出现的问题,
您没有创建包含所有库的node_modules文件夹,请转到终端中的项目根目录并运行以下命令。它将安装 package.json 文件中的所有模块。
npm install
注意:要查看是否安装了package.json文件中的节点模块,只需运行以下命令,方法是转到终端中的项目根目录
npm info
答案 1 :(得分:1)
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { MyCustomModule } from '../../lib';
@NgModule({
imports: [
BrowserModule,
MyCustomModule,
IonicModule.forRoot(AppComponent)
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule {
}
感谢Vikram Ezhil的时间。
默认情况下,Ionic支持的主题仍无效。
答案 2 :(得分:0)
我能够通过在 tsconfig.app.json
中禁用 angular ivy 编译器来解决这个问题"angularCompilerOptions": {
"enableIvy": false
},
...