![](/img/trans.png)
[英]I am unable to install react navigation using expo (react-native-gesture-handler isn't installed)
[英]I am trying to use onLongPress in react native with expo but it isn't working
任何人都可以闡明為什么onlongPress無法正常工作的原因。 我在EXPO中使用react native。 MapView是從expo導入的
<MapView.Marker
style={styles.map}
key={marker.pageid}
coordinate={coords}
description={`distance: ${marker.distance}m`}
longPressDelay={1000}
onLongPress={() => {
console.log('hit');
}}
onPress={() =>
this.map.fitToCoordinates(
[
{
latitude: this.props.latitude,
longitude: this.props.longitude
},
coords
],
{
edgePadding: {
top: 150,
right: 5,
bottom: 5,
left: 10
},
animated: true
}
)
}
>
這是因為Marker沒有onLongPress事件:)
您不會在MapView.Marker
上找到該onLongPress
事件。 您可以使用其他View進行包裝,在這種情況下,您會遇到樣式方面的問題,因此請相應地更新樣式。
或遵循這種方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.