Ionic 4 启动画面未隐藏在生产模式中
Ionic 4 splash screen not hiding in production mode
我已经构建了一个应用程序,一切正常。当我 运行 通过
应用程序时
ionic cordova run android
但是我 运行 生产模式启动画面中的应用程序没有隐藏。 platform.ready()
上也没有显示警报
ionic cordova run android --prod --release
这里是config.xml
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="SplashScreenDelay" value="3000" />
app.component.ts
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
alert('YES'); //this also not showing in production mode
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
对不起!我已经安装了一个原生插件 cordova-plugin-x-socialsharing
但我没有将它添加到 app.module.ts
中的 provider
数组。
将原生插件添加到 app.module.ts
后,一切都很完美。
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule
],
providers: [ // Add Native plugins in this array
StatusBar,
SplashScreen,
SocialSharing,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
我已经构建了一个应用程序,一切正常。当我 运行 通过
应用程序时ionic cordova run android
但是我 运行 生产模式启动画面中的应用程序没有隐藏。 platform.ready()
ionic cordova run android --prod --release
这里是config.xml
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="SplashScreenDelay" value="3000" />
app.component.ts
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
alert('YES'); //this also not showing in production mode
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
对不起!我已经安装了一个原生插件 cordova-plugin-x-socialsharing
但我没有将它添加到 app.module.ts
中的 provider
数组。
将原生插件添加到 app.module.ts
后,一切都很完美。
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule
],
providers: [ // Add Native plugins in this array
StatusBar,
SplashScreen,
SocialSharing,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}