bindcontroltap事件无法触发
发布于 6 年前 作者 kpeng 19200 次浏览 来自 问答

bindcontroltap事件无法触发,而bindtap事件可以直接触发。有没有大神给出解决方案?

2 回复

我的也触发不了,网官方解决哈

我也遇到这样的问题,使用教程中https://developers.weixin.qq.com/miniprogram/dev/component/map.html#map的示例,也无法触发在控制台输出e的对象。我自己练习的例子也无法触发bindcontroltap。

附加我的index.js代码:

const app=getApp();
 
Page({
   
  data: {
    longitude: "",
    latitude: "",
    controls: [{
        id: 1,
        iconPath: '/resources/target_2.png',
        position: {
          left: 10,
          top: app.globalData.windowHeight - 80,
          width: 25,
          height: 25
        },
        clickable: true
       },
        {
        iconPath: '/resources/red-pin.png',
        position: {
          left: (app.globalData.windowWidth/2)-12.5,
          top: (app.globalData.windowHeight-40)/2-25,
          width: 25,
          height: 25
        }
      }]
  },
 
  onReady(){
    console.log("onReady");
    this.mapCtx = wx.createMapContext("Map")
  },
 
  onShow(){
    this.getlocation();
  },
 
  getlocation(){
    wx.getLocation({
      type: 'gcj02',
      success: this.handleGetLocationSucc.bind(this)
    })
  },
 
  handleGetLocationSucc(res){
    this.setData({
      longitude: res.longitude,
      latitude: res.latitude
    })
  },
 
  controltap(e) {
    console.log("test");
    this.mapCtx.moveToLocation();
  },
 
  onShareAppMessage() {
    return {
      title: '萌宠交易平台',
      path: '/pages/index/index'
      }
    }
 
})

index.xml代码:

<!--index.wxml-->
<view class="map-container">
<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="14" class="map" controls="{{controls}}" bindcontroltap="controltap" show-location></map>
</view>
<view class="btns">
  <view class="btn btn_publish">发布</view>
  <view class="btn">搜索</view>
</view>

求各位帮忙分析下

回到顶部