0

我对 Angular 和打字稿相当陌生,但我有一个使用 Ionic 3 元素的 Angular 6 项目。

我正在尝试将本地保存的库从路径中的cdn../lib/ionic.bundle.js导入到我的项目中,但我收到模板解析错误,这表明模块没有为该路径导入。

Error: 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>


import { IonicApp, IonicModule } from '../lib/ionic.bundle.js';
const routes: Routes = [
  {
    path: 'create',
    component: CreateComponent
  },
  {
    path: 'edit/:id',
    component: EditComponent
  },
  {
    path: 'index',
    component: IndexComponent
  }
];

@NgModule({
  declarations: [
    CreateComponent,
    IndexComponent,
    EditComponent,
  ],
  imports: [
    IonicModule.forRoot(routes)
  ],
  providers: [ ...]
})
export class AppModule { }

我确信该文件存在于该路径中,但由于某种原因没有被导入。

有没有不同的导入方式IonicModule

4

1 回答 1

1

您应该尝试从中导入它node_modules

在项目目录的命令行中:

$ npm i ionic

安装ionic后,尝试从以下位置导入ionic-angular

import { IonicModule } from 'ionic-angular'
于 2019-03-14T08:38:00.717 回答