3

我正在尝试制作自己的自定义标签栏,似乎 tabBarComponent 是通过设置为我自己的组件来做到这一点的方法。使用下面的代码,我的标签栏不会出现。

const TabNav = TabNavigator({
  LaunchScreen: {
      screen: PrimaryNav,
      navigationOptions: {
        tabBarLabel:'Find',
        tabBarIcon: ({ tintColor }) => (
          <Icon name='search' size={20} color='white' />
        ),
      },
   },
}, {
  navigationOptions: {
    headerTintColor: 'grey'
  },
  tabBarComponent: FooterTabs,
  tabBarPosition: 'bottom',
  swipeEnabled:false,
  animationEnabled:false,
  lazy:true,
  tabBarOptions: {
      showIcon:true,
      showLabel:false,
      style: {
          backgroundColor: 'black'
      }
  }
});

在 FooterTabs.js 中:

export default class FooterTabs extends Component {
  render () {
    return (
      <View style={styles.container}>
        <Text>FooterTabs Component</Text>
      </View>
    )
  }
}

我错过了什么?

4

2 回答 2

3
    const TabNav = TabNavigator({
      ......,
     tabBarComponent: props => (
     <FooterTabs{...props} />
     ),
     tabBarPosition: 'bottom',
     ........

    });

试试看。附上你的 FooterTabs 即<FooterTabs />不是FooterTabs

于 2017-07-14T19:57:43.873 回答
1

经过反复试验,我的问题的解决方案是将页脚内容包装在 ScrollView 中,然后选项卡按预期显示,但我不确定为什么需要这样做。

我还实施了 Caleb 的建议(谢谢!),tabBarComponent: props => <FooterTabs{...props} />以便通过我需要的道具,尽管这不是问题的原因。

于 2017-07-15T06:09:16.250 回答