Component is part of the declaration of 2 modules

前端 未结 16 755
我在风中等你
我在风中等你 2020-12-04 06:44

I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine.

But when I try to build it every

16条回答
  •  臣服心动
    2020-12-04 07:14

    Since the Ionic 3.6.0 release every page generated using Ionic-CLI is now an Angular module. This means you've to add the module to your imports in the file src/app/app.module.ts

    import { BrowserModule } from "@angular/platform-browser";
    import { ErrorHandler, NgModule } from "@angular/core";
    import { IonicApp, IonicErrorHandler, IonicModule } from "ionic-angular";
    import { SplashScreen } from "@ionic-native/splash-screen";
    import { StatusBar } from "@ionic-native/status-bar";;
    
    import { MyApp } from "./app.component";
    import { HomePage } from "../pages/home/home"; // import the page
    import {HomePageModule} from "../pages/home/home.module"; // import the module
    
    @NgModule({
      declarations: [
        MyApp,
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        HomePageModule // declare the module
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage, // declare the page
      ],
      providers: [
        StatusBar,
        SplashScreen,
        { provide: ErrorHandler, useClass: IonicErrorHandler },
      ]
    })
    export class AppModule {}
    

提交回复
热议问题