0
例如,如果你想關閉該模式時,灰色的背景下(外中間的白色框中的任意位置)被點擊:你怎麼知道當一個視圖被挖掘,但它的孩子不是?
containerOnClick(e) {
if (isNotInsideChildView(e)) {
closeModal()
}
}
<TouchableWithoutFeedback
onPress={this.containerOnClick}
>
<View
style={{
backgroundColor: 'rgba(0, 0, 0, 0.5)',
flex: 1,
justifyContent: 'center',
}}
>
<View
style={{
backgroundColor: 'white',
padding: 10,
}}
>
<Text>dkfj</Text>
</View>
</View>
</TouchableWithoutFeedback>