【问题标题】:Not able to import IonicModule from path无法从路径导入 IonicModule
【发布时间】:2019-03-14 08:34:32
【问题描述】:

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

我正在尝试将一个从路径 ../lib/ionic.bundle.jscdn 本地保存的库导入到我的项目中,但我收到模板解析错误,这表明该模块未针对该路径导入。

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

【问题讨论】:

  • 你能提供你的文件夹结构吗?

标签: javascript angular typescript ionic3


【解决方案1】:

您应该尝试从 node_modules 导入它。

在项目目录的命令行中:

$ npm i ionic

安装ionic后,再从ionic-angular尝试importing

import { IonicModule } from 'ionic-angular'

【讨论】:

  • 我在那个文件夹中没有离子模块。完美运行!
猜你喜欢
  • 2018-05-13
  • 2018-11-26
  • 2014-05-06
  • 1970-01-01
  • 1970-01-01
  • 2013-04-16
  • 1970-01-01
  • 1970-01-01
  • 2021-11-13
相关资源
最近更新 更多