大家好,我使用wx.chooseLocation 获取地址后,res.latitude,res.longitude 值赋值给自定义变量,代码如下:
getLocalPath: function (e) {
var that = this;
wx.chooseLocation({
success: function (res) {
console.log(res) //获取位置
that.setData({
// localPath: res.address,
latitudeX: res.latitude,
longitudeY: res.longitude,
markers: [{
id: 1,
latitude: res.latitude,
longitude: res.longitude,
iconPath: '../images/Map-pin 6.png',
callout: {
content: _('提醒:如果获取的地址有误,请拖动选择地址'),
bgColor: "#fff",
padding: "5px",
borderRadius: "2px",
borderWidth: "1px",
borderColor: "#07c160",
}
}],
});
console.log(res.latitude)
console.log(res.longitude)
console.log(that.data.latitudeX)
console.log(that.data.latitudeY)
},
});
},
最终打印赋值情况,结果如下:
{errMsg: "chooseLocation:ok", name: "", address: "", latitude: 43.84367, longitude: 87.574}
43.84367
87.574
43.84367
undefined
明明获取到了,为什么赋值后undefined?
longitudeY 你是认真的吗