【问题标题】:Tabs showing wrong title标签显示错误的标题
【发布时间】:2019-07-15 11:56:59
【问题描述】:

我正在开发 react-native 移动应用。升级RN版本和react-native-router-flux ^4.0.6后。我正在使用类似于 ]

它必须显示Tabs,标题为HOMECATEGORIESSuccess stories。但据观察,它不断获取抽屉的标题,标签看起来像这样HomemainTitlemainTitle。其中主标题是在抽屉上设置的标题。

只有显示正确的标签是带有初始标签的标签。

期望:标签将在抽屉下方的屏幕上显示其标题。 现实:每次都显示抽屉菜单的标题。 这是我的代码。



    <Drawer
                initial
                navigationBarStyle={Styles.navigationBarStyle} key="drawer"
                contentComponent={DrawerMenu} drawerWidth={220}
                drawerIcon={<Icon name='menu' color={Colors.black} size={30}
                                  style={{marginTop: Platform.OS === 'ios' ? -5 : 0}}
                                  onPress={this.handleDrawerIconPress}/>}
                title='main Title' rightTitle=' '
              >
                <Tabs
                  initial
                  tabBarPosition="top"
                  key="tabbar"
                  swipeEnabled
                  showLabel={false}
                  activeBackgroundColor={Colors.pink}
                  activeTintColor={Colors.pink}
                  inActiveTintColor={Colors.black}
                  inactiveBackgroundColor={Colors.black}
                  tabBarStyle={Styles.tabBar}
                  indicatorStyle={Styles.indicatorStyle}
                  iconStyle={Styles.iconStyle}
                  showIcon={true}
                >
                  <Scene
                    initial
                    key="home"
                    component={Home}
                    icon={TabsIcon}
                    title="HOME"
                    iconName='home'
                    hideNavBar
                  />
                  <Scene
                    key="categories"
                    component={Categories}
                    title="CATEGORIES"
                    icon={TabsIcon}
                    iconName='categories'
                    hideNavBar
                  />
                  <Scene
                    key="success"
                    component={SuccessStories}
                    title="SUCCESS STORIES"
                    icon={TabsIcon}
                    iconName='success-stories'
                    hideNavBar
                  />
                </Tabs>
              </Drawer>

【问题讨论】:

  • 用tabBarLabel更改标题是否有效?
  • 如果我使用 tabBarLabel 它什么也不显示。
  • 如果你删除showLabel={false}他们会出现
  • 是的,我删除了 showlabel= {false} 但仍然没有影响
  • 你能给我看一张抽屉照片吗?

标签: android reactjs react-native react-native-router-flux


【解决方案1】:

花了几个小时后,我能够修复它。实际上react-native-router-flux 没有他们文档中提到的任何标题属性。 react-native-router-flux-documentation。所以我刚刚得到了一个技巧来解决我的问题,那就是我在drawer 中使用了getTitle 而不是title。我的代码现在是这样的

    <Drawer
        initial
        navigationBarStyle={Styles.navigationBarStyle} key="drawer"
        contentComponent={DrawerMenu} drawerWidth={220}
        drawerIcon={<Icon name='menu' color={Colors.black} size={30}
                          style={{marginTop: Platform.OS === 'ios' ? -5 : 0}}
                          onPress={this.handleDrawerIconPress}/>}
        getTitle="Main Title"  rightTitle=' '
     >

它解决了我的问题。感谢所有看过它的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 2011-01-03
    相关资源
    最近更新 更多