ionic3 清除“启动白屏”打包报错

1.如用正常打包命令,可以通过:ionic cordova build android
2.如用清除“白屏”方法打包,则报错:ionic cordova build android --prod --release

在config.xml里加如下代码:

<preference name="AutoHideSplashScreen" value="false" />  
<preference name="ShowSplashScreen" value="true" />  
<preference name="ShowSplashScreenSpinner" value="false" />  
<preference name="FadeSplashScreen" value="true" />

报错如下:
图片描述

各位如何解决的?

answer.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { AnswerPage } from './answer';

@NgModule({
  declarations: [
    AnswerPage,
  ],
  imports: [
    IonicPageModule.forChild(AnswerPage),
  ],
})
export class AnswerPageModule {}
阅读 2.5k
1 个回答

与你的打包方式无关,是你的代码有问题,提示说 AnswerPage 声明了两次,一次在AppMoudle,一次在AnswerPagemodule。你看下是不是重复声明。

看到你贴的代码,我知道你错误的原因了。你把懒加载的页面和正常加载的页面弄混了。
正常加载的页面使用ionic generate component xx创建,然后在AppModule中声明。懒加载的页面使用ionic generate page xx创建,无需在AppModule中声明,它很明显的一点是代码开头有@ionicpage()这样的装饰器。

你没有好好的看官方文档,特别是API中关于Controller这个部分。

你可以去我github上fork一下我写的简单基础的ionic项目hw-basic,希望对你有帮助。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进