我是Ionic 3的新手。我已经完成了一个应用程序,并试图转换为apk。
我正在使用以下CLI生成调试(或测试)android-debug.apk:
ionic cordova build android --prod
页面在声明和entryComponents中进行声明。
这是我的 app.module.ts
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthServiceProvider
]
})
export class AppModule {}
错误:
答案 0 :(得分:1)
您要将同一组件放入多个ngModule数组中。尝试将其添加到上级模块中。
如果您想在多个模块中使用相同的组件,请尝试使其成为一个单独的模块,然后将该组件导出到该模块中
your.module.ts
declarations: [
YourComponent,
],
imports: [
CommonModule,
ReactiveFormsModule,
],
exports: [YourComponent]
修改:1
不能在多个模块中注册一个组件。如果要在多个不同模块中使用相同组件。尝试使该组件成为一个单独的模块,然后将该模块导入所需的任何位置。就您而言,从应用程序模块的声明中删除EditProfilePage并将此行添加到您的EditProfilePageModule中。
EditProfilePageModule.ts
exports: [EditProfilePage]
现在在您的app.module.ts中,导入EditProfilePage模块
app.module.ts
imports: [
CommonModule,
EditProfilePageModule,
],