我想禁用View下面的可觸摸性。所以我不希望 console.log 在按下黃色方塊時運行。我用過pointerEvents,但沒有用。我怎樣才能做到這一點?
import { Text, TouchableOpacity, View, } from "react-native"
import React from "react"
export default function Screen() {
return (
<TouchableOpacity
style={{ flex: 1, backgroundColor: "black" }}
onPress={() => console.log("pressed")}
>
<View
style={{ width: 100, height: 100, backgroundColor: "yellow" }}
pointerEvents="none"
>
<Text>React Native</Text>
</View>
</TouchableOpacity>
)
}
uj5u.com熱心網友回復:
<TouchableOpacity
style={{ flex: 1, backgroundColor: "black" }}
onPress={() => console.log("pressed")} >
<TouchableOpacity activeOpacity={1}>
<View
style={{ width: 100, height: 100, backgroundColor: "yellow" }}>
<Text>React Native</Text>
</View>
</TouchableOpacity>
</TouchableOpacity>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/521114.html
上一篇:React-Native)如何檢索陣列中的物件值|縮小反應錯誤#301
下一篇:反應映射組件的變化狀態
