ionic3啟動白屏優化
阿新 • • 發佈:2019-02-15
-
1、在config.xml檔案中修改配置
<preference name="ShowSplashScreen" value="true" /> <preference name="SplashScreen" value="screen" /> <preference name="SplashScreenDelay" value="3000" /> <preference name="AutoHideSplashScreen" value="false" /> <preference name="SplashShowOnlyFirstTime" value="false" /> <preference name="FadeSplashScreen" value="false" /> <feature name="SplashScreen"> <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" /> </feature>
ShowSplashScreenSpinner——是否顯示啟動屏轉圈圈那個 Spinner;
AutoHideSplashScreen——是否自動隱藏SplashScreen;
FadeSplashScreen——是否逐漸消失SplashScreen;
SplashScreenBackgroundColor——背景顏色;
SplashMaintainAspectRatio——如果值設定為 true,則影象將不會伸展到適合螢幕。如果設定為 false ,它將被拉伸;
FadeSplashScreenDuration——逐漸消失SplashScreen的動畫時延;
SplashShowOnlyFirstTime——是否只第一次顯示;
SplashScreen——它是 platform / android / res / drawable - 資料夾中的影象的名稱。Cordova預設生成 screen.png 圖片;
SplashScreenDelay——SplashScreen顯示的延時時間
-
2、在app.component.ts中隱藏初始載入圖片
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, public backButtonService: BackButtonProvider, ) { this.initializeApp(); } initializeApp() { this.platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. this.statusBar.styleDefault(); // this.splashScreen.hide(); // 隱藏初始載入圖片 setTimeout(() => { this.splashScreen.hide(); }, 1000); this.backButtonService.registerBackButtonAction(null); }); }
-
3、打包優化
ionic cordova build android --prod