首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >createBottomTabNavigator如何修改标题?

createBottomTabNavigator如何修改标题?
EN

Stack Overflow用户
提问于 2019-11-29 16:20:13
回答 1查看 469关注 0票数 0

mycode

routers.js

代码语言:javascript
复制
import {createBottomTabNavigator} from 'react-navigation-tabs';

import home from '../views/home';
import my from '../views/my';

const RouteConfigs = {
  home: {
    screen: home, // This attribute works
    tabBarLabel: 'cc', // Why he didn't work
    showLabel: false, // Why he didn't work
  },
  my: {
    screen: my,
  },
};

const TabOptions = {
  swipeEnabled: true,
  animationEnabled: true,
};

const StackNavigator = createBottomTabNavigator(RouteConfigs, TabOptions);

export default StackNavigator;
代码语言:javascript
复制
import {createAppContainer} from 'react-navigation';

import routers from './routers';

export default createAppContainer(routers);

问题

应为:'cc','my‘

但实际的结果是:“家”,“我的”

代码语言:javascript
复制
screen: home, // This attribute works
tabBarLabel: 'cc', // Why he didn't work
showLabel: false, // Why he didn't work

文档:https://reactnavigation.org/docs/en/bottom-tab-navigator.html

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-29 16:41:18

您必须将它们作为navigationOptions传递:

代码语言:javascript
复制
  home: {
    screen: home, 
    navigationOptions: {
        tabBarLabel: "cc"
    }
  }

关于标签部分,您只能在bottomTabNavigator上全局更改它:

代码语言:javascript
复制
const TabOptions = {
   swipeEnabled: true,
   animationEnabled: true,
   tabBarOptions: {
      showLabel : false
   }
};

如果您想将其隐藏在特定选项卡中,您可以传递:

代码语言:javascript
复制
navigationOptions: {
    tabBarLabel: " "
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59101122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档