博览会:如何以编程方式更改初始图像?

我有一个React Native Expo app.json,如下所示:

{
  "expo": {
    "name": "Awesome App","splash": {
      "image": "./assets/images/splash.jpg",},...
}

在我的App中,我希望允许用户从(从服务器加载的)图像列表中选择一个图像,该图像将在用户下次启动该应用时显示在初始屏幕中。

我该如何使用Expo?

oji6695 回答:博览会:如何以编程方式更改初始图像?

您将使用反应导航。只需在stackNavigator中添加splashScreen

export default StackNavigator({
  SplashScreen: { screen: SplashScreen },AuthScreen: { screen: AuthScreen },MainNavigator: { screen: MainNavigator }
},{
  headerMode: 'screen',navigationOptions: {
    header: { visible: false }
  }
})

添加超时。就我而言

componentDidUpdate () {
  if (this.state.isAppReady) {
    if (this.state.isLoggedIn) {
      this.props.navigation.navigate('MainNavigator');
    } else {
      this.props.navigation.navigate('AuthScreen');
    }
  }
}

您可以在渲染中更改图像。

本文链接:https://www.f2er.com/2900729.html

大家都在问