react-native – 在React Native中,TabBarBottom不显示图标/图像

我几乎从TabNavigator文档中获取了示例代码,而图标/图像根本没有出现在iOS或 Android上.即使标签覆盖似乎也没有生效.我究竟做错了什么?

这是我一直在使用的文档的链接:
https://reactnavigation.org/docs/navigators/tab

这是我的代码:

class MyHomeScreen extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Not displayed',// Note: By default the icon is only shown on iOS. Search the showIcon option below.
    tabBarIcon: ({ tintColor }) => (
      <Image
        source={require('./chats-icon.png')}
        style={[styles.icon,{tintColor: tintColor}]}
      />
    ),};

  render() {
    return (
      <Button
        onPress={() => this.props.navigation.navigate('Notifications')}
        title="Go to notifications"
      />
    );
  }
}

class MyNotificationsScreen extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Notifications',tabBarIcon: ({ tintColor }) => (
      <Image
        source={require('./notif-icon.png')}
        style={[styles.icon,};

  render() {
    return (
      <Button
        onPress={() => this.props.navigation.goBack()}
        title="Go back home"
      />
    );
  }
}

const styles = StyleSheet.create({
  icon: {
    width: 26,height: 26,},});

const MyApp = TabNavigator({
  Displayed: {
    screen: MyHomeScreen,Notifications: {
    screen: MyNotificationsScreen,{
  tabBarOptions: {
    activeTintColor: '#e91e63',});
好吧,在我想把脸撞到键盘上后,我终于想通了.

标题和标签栏图标实际上是与文档内部不同的结构.

const MyApp = TabNavigator({
    Displayed: {
      screen: MyHomeScreen,navigationOptions: {
          title: 'Favorites',tabBar: {
            icon: ({tintColor}) => (<Image
              source={require('./chats-icon.png')}
              style={{width: 26,tintColor: tintColor}}
            />)
          },...

要么

class MyHomeScreen extends React.Component {
    static navigationOptions = {
        title: 'Foo Bar',tabBar: {
            icon: ({ tintColor }) => (
              <Image
                source={require('./chats-icon.png')}
                style={{width: 26,tintColor: tintColor}}
              />
            ),}
      };
 ...

相关文章

一、前言 在组件方面react和Vue一样的,核心思想玩的就是组件...
前言: 前段时间学习完react后,刚好就接到公司一个react项目...
前言: 最近收到组长通知我们项目组后面新开的项目准备统一技...
react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...