在createbottomtabsnavigator中调用函数

我正在使用本机反应,我想在选项卡中调用函数

import {createBottomTabNavigator} from 'react-navigation-tabs';

const TabNavigator = createBottomTabNavigator(  
    {  
      Home:{  
        screen:CustomMapView,navigationOptions:{  
          tabBarLabel:'Home',tabBarIcon:({tintColor})=>(  
              <Image source = {require("../../Images/react-logo.png")} style={{width : 30,height:30}}/> 
          )  
        }  
      },Profile11:{  
        screen:Profile11,navigationOptions:{  
          tabBarLabel:'Profile11',Profile: {  
        screen:ProfileScreen,navigationOptions:{  
          tabBarLabel:'Profile',tabBarIcon:({tintColor})=>(  
              // <Icon name="ios-person" color={tintColor} size={25}/>  
            <Image source = {require("../../Images/react-logo.png")} style={{width : 30,},{  
      initialRouteName: "Home"  
    },);  

我在上面使用的方法是,如果条件为true,则要在首页等选项卡上设置一些条件,如果条件为false,则将CustomMapView设置为屏幕;如果条件为false,则其他任何屏幕都将像CustomMapView.js一样设置

我该怎么做

eiance 回答:在createbottomtabsnavigator中调用函数

如果要设置呈现页面的条件,请检查以下示例:

const MainApp = createBottomTabNavigator(
  {
    Home: HomeTab,Settings: SettingsTab,},{
    defaultNavigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused,horizontal,tintColor }) => {
        const { routeName } = navigation.state;
        if (routeName === 'Home') {
          return (
            <Image
              source={ require('./assets/home.png') }
              style={{ width: 20,height: 20,}} />
          );
        } else {
          return (
            <Image
              source={ require('./assets/settings.png') }
              style={{ width: 20,height: 20 }} />
          );
        }
      },}),tabBarOptions: {
      activeTintColor: '#FF6F00',inactiveTintColor: '#263238',});

如果要在Tab键按下时调用方法,请参考以下示例:

Profile: {  
    screen:ProfileScreen,navigationOptions:{  
      tabBarLabel:'Profile',tabBarIcon:({tintColor})=>(  
          // <Icon name="ios-person" color={tintColor} size={25}/>  
        <Image source = {require("../../Images/react-logo.png")} style={{width : 30,height:30}}/> 
      ),tabBarOnPress: () => { this.openGallery() }  
    }  
  },
本文链接:https://www.f2er.com/3123989.html

大家都在问