解决小程序开发自定义组件getCenterLocation无法回调问题
在创建map上下文时第二个参数传入this
ready: function () {
this.mapCtx = wx.createMapContext('myMap', this);
},
methods: {
mapChange: function() {
let self = this;
this.mapCtx.getCenterLocation({
success: function(res) {
console.log(res)
self.setData({
nearList: [],
latitude: res.latitude,
longitude: res.longitude,
})
}
})
}
}