Map上面一个View(内含button),一次点击两个控件都触发?
发布于 4 年前 作者 leifeng 1881 次浏览 来自 问答

Map是底层,全图显示,上层有一个使用绝对定位设置的view,内部含有两个button,大概代码如下。现在点击这个button,不仅仅会触发button的tap,也会触发map的tap,这种情况如何解决?我只需要触发上层button的tap事件即可。

<view class="page-body">
  <view class="page-section page-section-gap">
    
    <map id="myMap" style="width: 100vw; height: 100vh;" latitude="{{latitude}}" longitude="{{longitude}}" enable-satellite="false"
      markers="{{markers}}" scale="{{map_scale}}" bindtap="onMapTap" bindmarkertap="onPointTap" show-location="true">
      <view class="search_bar">
        <image src="/image/search.png" style="width:50rpx;height:50rpx;padding-right:10px;" />
        <input class="search_view" bindblur="closesuggest" bindconfirm="getsuggest" type="text" confirm-type="search"
          value="{{backfill}}" placeholder="输入地址定位(如: 人民广场)">input>

      view>     map>   view>   <view class=“btn-area”>     <button class=“help-button” style=“padding:0;width:100rpx;” bindtap=“showHelp” hover-class=“help-button-pressed”>       <image src="/image/help.png" style=“width:80rpx;height:80rpx;” />     button>     <button class=“reset-button” style=“padding:0;width:100rpx;” bindtap=“moveToCurrentLocation” hover-class=“reset-button-pressed”>       <image src="/image/gps.png" style=“width:80rpx;height:80rpx;” />     button>   view> view>

1 回复

1、可以将bindtap换为catchtap

2、提成index层级 如果你这里用的view 应该是不会覆盖掉map上,因为map的层级是最高的,可以考虑将view换为cover-view,button自己用cover-view写一套样式。

回到顶部