小编mor*_*fer的帖子

另一个TouchableOpacity内的Stacked TouchableOpacity无法点击

即使本文档(https://facebook.github.io/react-native/docs/gesture-responder-system.html)指出,触摸事件也会传递给子节点,并且仅由父节点使用,如果孩子对事件没有反应,我面对的问题是,嵌套在另一个TouchableOpacity内的TouchableOpacity对触摸没有正确反应.

我的结构如下

<ScrollView>
  <TouchableOpacity onPress={() => console.log('This is printed always')}>
    <View>
      <Text>I can click here</Text>
      <TouchableOpacity onPress={() => console.log('This is printed never')}>
        <Text>I can click here but the outer onPress is called instead of the inner one</text>
      </TouchableOpacity>
    </View>
  </TouchableOpacity>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

TouchableOpacitys中的按钮也是如此:单击按钮调用父TouchableOpacity的onPress方法

我在监督什么吗?

android react-native touchableopacity

13
推荐指数
3
解决办法
4323
查看次数

标签 统计

android ×1

react-native ×1

touchableopacity ×1