简体   繁体   English

ionic 2抛出:在“导入”中找不到IonicModule.forRoot调用

[英]ionic 2 throws : Could not find IonicModule.forRoot call in “imports”

I am now adding ionic 2 into my current angular4 project. 我现在将ionic 2添加到当前的angular4项目中。

In the app.module, 在app.module中,

import {NgModule} from '@angular/core'
import { BrowserModule } from '@angular/platform-browser';
import {AppComponent} from './app.component'
@NgModule( {
    imports: [BrowserModule, IonicModule.forRoot( AppComponent )],
    declarations: [AppComponent],
    bootstrap: [IonicApp],
    entryComponents: [
        AppComponent
    ]
})
export class AppModule { }

but when I use "ionic serve", I kept having this error: 但是当我使用“离子发球机”时,却一直出现此错误:

00:00:15]  ionic-app-script task: "serve" 
[00:00:15]  Error: Could not find IonicModule.forRoot call in "imports" 
Error: Could not find IonicModule.forRoot call in "imports"

Obviously, i is already there, why the error is still thrown? 显然,我已经在那里,为什么仍然抛出错误?

Thanks 谢谢

  • Go to "app.module.ts" in the src/app folder (src/app/app.module.ts) 转到src / app文件夹(src / app / app.module.ts)中的“ app.module.ts”
  • Open it 打开它
  • Search for "imports" 搜索“进口”

      imports: [ BrowserModule, HttpClientModule, ] 
  • Insert the following line : 插入以下行:

      IonicModule.forRoot(MyApp) 

您需要从ionic-angular导入模块。

import {IonicApp, IonicModule} from 'ionic-angular';

将此添加到您的app.module

import { IonicModule} from 'ionic-angular';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM