簡體   English   中英

如何避免 onPress function 在 React-Native 的內部視圖中工作

[英]How to avoid onPress function works inside the inner Views in React-Native

我想避免onPress={() => onRequestClose()} function 在我的 react-native 項目的內部View中工作。

當用戶點擊屏幕時(無論區域) onPress={() => onRequestClose()}工作,以避免我在第一個TouchableWithoutFeedbackView組件內使用View我添加了另一個TouchableWithoutFeedback 但這不起作用。

我正在努力尋找解決方案,有什么方法可以解決這個問題。

我的代碼如下

<View style={styles.videoOverlayWrapper}>
    <TouchableWithoutFeedback onPress={() => onRequestClose()} style={{width: '100%', height: '100%'}}>
    <View><TouchableWithoutFeedback onPress={()=>{}}>{props.children}</TouchableWithoutFeedback></View>
    </TouchableWithoutFeedback>
</View>

在此處輸入圖像描述

您可以在任何 onPress 中傳遞 null,如 onPress={() => null} 或 onPress={null}

<View style={styles.videoOverlayWrapper}>
    <TouchableWithoutFeedback onPress={() => null} style={{width: '100%', height: '100%'}}>
</View>

你能分享你的觀點風格嗎 styles.videoOverlayWrapper

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM