如何在离子2中的闪屏后摆脱白色屏幕

时间:2017-02-28 13:49:41

标签: angular typescript angularjs-directive cordova-plugins

如何在离子2中的闪屏后摆脱白屏?

@peka。我已经尝试了几次,但它仍然在启动画面后给我一个白色的屏幕。最诚挚的问候

import { Component } from '@angular/core';
import { Platform} from 'ionic-angular';
import { StatusBar, Splashscreen,SQLite } from 'ionic-native';

import { HomePage } from '../pages/home/home';


@Component({
  templateUrl: 'app.html'
})
export class MyApp{
  rootPage = HomePage;

  constructor(platform: Platform) {
    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.
      StatusBar.styleDefault();
      Splashscreen.hide();

      let db = new SQLite();
      db.openDatabase({
        name: "data.db",
        location: "default"
      }).then(() => {
        db.executeSql("CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)", {}).then((data) => {
          console.log("TABLE CREATED: ", data);
        }, (error) => {
          console.error("Unable to execute sql", error);
        })
      }, (error) => {
        console.error("Unable to open database", error);
      });
    });
  }

}

1 个答案:

答案 0 :(得分:0)

将以下首选项添加到根目录中的config.xml:

<preference name="AutoHideSplashScreen" value="false"/>

禁用AutoHideSplashScreen覆盖SplashScreenDelay,当平台准备就绪后,Splashscreen.hide()将生效。

参考:https://github.com/apache/cordova-plugin-splashscreen#configxml