小程序告警,但是无法定位问题
发布于 5 年前 作者 tao15 15821 次浏览 来自 问答

类型:脚本错误

错误样例: undefined is not an object (evaluating ‘a.mapCtx.getCenterLocation’);at pages/location/location page regionchange function

以下是相关代码:

.js:

regionchange:function(e){

    var that = this;

      if(e.type=='end'){

        // this.getCenterLocation();

        that.mapCtx.getCenterLocation({

            success: function (res) {

                that.setData({

                    m_latitude: res.latitude,

                    m_longitude: res.longitude

                })

                that.requestData(res.longitude, res.latitude, 0);

            }

        })

      }

},

.wxml

<map wx:if="{{show_tab_list==0}}" id=“aokeNear” longitude="{{longitude}}" latitude="{{latitude}}"  markers="{{markers}}"  bindmarkertap=“onMarkerClick” scale=“15” show-location=“true” bindregionchange=“regionchange” controls="{{controls}}" bindcontroltap=“bindcontrol”>

</map>

代码很简单,逻辑也很简单,不知道是什么原因造成的告警。有没有知道的朋友,麻烦帮忙看看,万分感谢~

2 回复

有官方解答吗?是api的问题吗?不处理这个警告会有什么后果?

mapCtx.getCenterLocation’这个获取到undefined,所以报错

回到顶部