ionic项目中,在splashscreen消失后会出现零点几秒的白屏,再出现app页面。
1. 安装Cordova splash screen插件
ionic plugin add org.apache.cordova.splashscreen
2.修改ionic项目的config.xml 文件
<!-- set splash screen -->
<preference name="SplashScreen" value="screen"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="ShowSplashScreenSpinner" value="false"/>
<preference name="SplashMaintainAspectRatio" value="true"/>
<preference name="SplashShowOnlyFirstTime" value="false"/>
<preference name="SplashScreenDelay" value="5000"/>
<preference name="FadeSplashScreen" value="false"/>
3.不让闪屏自动隐藏,而在代码中手动隐藏splash screen
$ionicPlatform.ready(function () {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true); //延迟splash screnn 隐藏时间,不然会有短暂的白屏出现
setTimeout(function () { navigator.splashscreen.hide(); }, 1000);
}
});
执行 ionic build android 生成apk文件,安装运行,发现确实管用