相关疑难解决方法(0)

如何在tabnavigator中使用tabBarOnPress反应本机

当我单击选项卡时,我陷入了一个大问题,即我想要onPress事件。我的代码在这里:

static navigationOptions = ({navigation, screenProps}) => {
   const params = navigation.state.params || {};
   console.log("Params:-",params);
  return {
        title:Strings.title_dashboard,
        headerStyle:{ backgroundColor: Colors.header_blue},
        headerTitleStyle:HeaderStyle.titleCenter,
        tabBarOnPress: (tab, jumpToIndex) => {
           console.log("Tab Click",tab);
            jumpToIndex(tab.index);
            navigation.state.params.onFocus()
        },
       headerRight:<TouchableOpacity onPress={()=>Alert.alert(Strings.avanza,Strings.under_imple)}><View><Image source={{uri: "filter_icon"}} style={{height: 18, width: 18,marginRight:10,}} /></View></TouchableOpacity>,
  }
  }
Run Code Online (Sandbox Code Playgroud)

在这里,我在componentDidMount中设置如下参数:

this.props.navigation.setParams({
      handleGrid: this.callServer.bind(this)
    })
Run Code Online (Sandbox Code Playgroud)

在这里出现错误,无法获得此点击事件。

请帮帮我。

谢谢。

react-native

5
推荐指数
2
解决办法
7792
查看次数

标签 统计

react-native ×1