簡體   English   中英

我正在嘗試在反應本機中使用onLongPress與expo進行交互,但是它不起作用

[英]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.

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