最佳答案
我遇到了一个奇怪的问题。在我的反应本机应用程序,如果我设置 onPress
事件为 View
,它不会被触发,但如果我设置相同的 Text
内的 View
,它触发。我错过了什么?
<View style={{backgroundColor: "red", padding: 20}}>
<Text onPress={()=> {
console.log('works');
}
}>X</Text>
</View>
<View style={{backgroundColor: "red", padding: 20}} onPress={()=> {
console.log('does not work');
}
}>
<Text>X</Text>
</View>
为什么会这样? 这是反应原生的问题吗? 我使用的是0.43版本