Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The navigation bar title is not displayed,used createBottomTabNavigator createStackNavigator #4961

Closed
asd8855 opened this issue Sep 8, 2018 · 4 comments

Comments

@asd8855
Copy link

asd8855 commented Sep 8, 2018

"react": "16.4.1",
"react-native": "0.56.0",
"react-navigation": "^2.13.0",
node v10.7.0
npm 6.4.1

const TabStack = createBottomTabNavigator({
Home: {screen: HomeScreen},
Work: { screen: WorkScreen },
Me: { screen: MeScreen }
});

const RootStack = createStackNavigator({
TabBar: { screen: TabStack },
Detail: { screen: DetailScreen }
});

export default class App extends React.Component {
render() {
return ;
}
}

static navigationOptions = {
title: "首页",
headerTitle: "首页", //对页面的配置
tabBarLabel: '首页',
};

@asd8855 asd8855 changed the title The navigation bar title is not displayed,used createBottomTabNavigator createBottomTabNavigator The navigation bar title is not displayed,used createBottomTabNavigator createStackNavigator Sep 8, 2018
@asd8855
Copy link
Author

asd8855 commented Sep 8, 2018

simulator screen shot - iphone x - 2018-09-09 at 00 04 10

@eriveltonelias
Copy link
Member

Hi @asd8855!

Can create a runnable example on https://snack.expo.io ?

@luckforyou
Copy link

@asd8855 你好,我也遇到与你相同的问题。
用下面的一段代码可以解决,但是不是很优雅。具体什么原因估计需要读源码进行解决。

// 不写函数,标题不是显示
TabStack.navigationOptions = ({ navigation }) => {
  let { routeName } = navigation.state.routes[navigation.state.index];
  let title;
  //do something like
  if (routeName === 'Home') {
    title = '微信';
  } else if (routeName === 'Work') {
    title = '通讯录';
  } else if (routeName === 'Me') {
    title = '发现';
  } 
  return {
    title,
  };
};

相当的不优雅,有时间再慢慢研究吧!

@eriveltonelias
Copy link
Member

closing this because of no repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants