无法从路径导入 IonicModule

Not able to import IonicModule from path

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

我正在尝试将一个从 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

您应该尝试从 node_modules 导入它。

在您的项目目录的命令行中:

$ npm i ionic

ionic-angular 安装 ionic, then try importing 后:

import { IonicModule } from 'ionic-angular'