在应用启动之前预加载数据以设置根页面

时间:2018-12-18 15:31:21

标签: angular typescript ionic-framework ionic3 angular5

在我的Ionic 3应用程序启动时(可见初始屏幕时),我想进行API调用,并检查用户数据,然后据此确定他的登录页面。

我已经这样做了,但是用户被重定向到默认页面,直到返回API调用,然后用户才被扎根到正确的页面。该过程持续200毫秒,但由于屏幕已更改,因此UX效果不佳。如何预加载数据(在显示任何页面之前先进行API调用,然后根据API返回的数据将NavController rootPage设置为某个页面?

这是我到目前为止所做的

platform.ready().then(() => {
  settings.getValue('is_tour_done').then((val) => {
    if (val === null) {
      return this.rootPage = TourPage;
    }

    if (!this.oauth.hasValidAccessToken()) {
      this.rootPage = LoginPage;
    }

    this.statusBar.hide();
    this.splashScreen.hide();
  });
});

在我的主要组件中

1 个答案:

答案 0 :(得分:0)

您需要禁用启动画面输出关闭。检查下面config.xml中的属性

<preference name=”FadeSplashScreen” value=”false”/>
<preference name=”AutoHideSplashScreen” value=”false”/>
相关问题