React Native - 更改navigationOptions标题组件切换标签

时间:2017-10-09 02:04:28

标签: javascript android ios react-native react-navigation

我对docs和stackoverflow做了一些研究,找不到任何相关的帖子/文档。 我使用TabNavigator和StackNavigator进行应用程序导航,我想在切换标签时更改navigationOption标头组件。我有3个标签HomeLiveRadio

示例 - 当标签是Home标题组件时

<View><ScrollView><GenerateList_1/></ScrollView></View>

当标签是Live标头组件

<View><ScrollView><GenerateList_2/></ScrollView></View>

const mainNav = TabNavigator({
  Home: { screen: HomeScreen},
  Live: { screen: LiveScreen },
  Radio: { screen: RadioScreen},
} );

export const mainStack = StackNavigator({
  Home: { 
    screen: mainNav,
    navigationOptions: {
      header: (
              <View style={styles.topnavscrollview}>
                <View style={{width:300}}>
                  <ScrollView horizontal={true} showsHorizontalScrollIndicator={false}>
                    <GenerateList_1/> <-- Change this when switch to Live tab or others
                  </ScrollView>
                </View>
              </View>
      ),
    },
  },
  Content: { screen: ContentScreen },
});

当前标题在每个标签上共享

0 个答案:

没有答案