簡體   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