繁体   English   中英

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

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

我现在将ionic 2添加到当前的angular4项目中。

在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 { }

但是当我使用“离子发球机”时,却一直出现此错误:

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"

显然,我已经在那里,为什么仍然抛出错误?

谢谢

  • 转到src / app文件夹(src / app / app.module.ts)中的“ app.module.ts”
  • 打开它
  • 搜索“进口”

      imports: [ BrowserModule, HttpClientModule, ] 
  • 插入以下行:

      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