react native 给View添加点击事件

http://www.voidcn.com/article/p-vijhprhu-buo.html

 

直接在View上绑定点击事件,是没有用的。要使任何元素处理React-Native UI中的触摸/单击事件,您需要将元素放在TouchableOpacity,TouchableWithoutFeedback,TouchableNativeFeedback或TouchableHighlight元素中:

<TouchableHighlight onPress = { this.onClick }>
    <View style={styles.container}>
    <Text style={styles.welcome}>
        Tap to change the background
    </Text>
    </View>
</TouchableHighlight>
posted @ 2020-01-16 17:10  liuw_flexi  阅读(7368)  评论(0编辑  收藏  举报