首页 > 解决方案 > 指标未在 iOS 和 Android 上呈现

问题描述

我正在尝试在选项卡导航上呈现 topBar,但它没有显示

import { createBottomTabNavigator, createAppContainer } from "react-navigation";

const TabNavigator = createBottomTabNavigator(
  {
    Dashboard: {
      screen: Dashboard,
      navigationOptions: {
        title: "Dashboard",
        tabBarIcon: ({ tintColor }) => (
          <Icon
            name="home"
            type="Entypo"
            style={{
              color: tintColor,
            }}
            color={tintColor}
          />
        ),
      },
    },
  },
  {
    tabBarPosition: "top",
    tabBarOptions: {
      activeTintColor: "#5D10F6",
      inactiveTintColor: "gray",
      showIcon: true,
      tintColor: "#333",
      animationEnabled: false,
      showLabel: false,
      scrollEnabled: true,
      tabBarPosition: "top",
      indicatorStyle: {
        backgroundColor: "red",
      },
    },
  }
);

标签: react-native

解决方案


注意:createTabNavigator 在 react-navigation@3.x 中被移除。请改用 createBottomTabNavigator 和/或 createMaterialTopTabNavigator。

但是createBottomTabNavigator不再支持 indicatorStyle :(


推荐阅读