繁体   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