如题,本意是点击按钮上传位置信息到云开发数据库,代码如下,感谢各位大牛指路!
upload: function () {
var that=this;
wx.getLocation({
type: 'gcj02',
altitude: true,
//定位成功,更新定位结果
success: function(res) {
var latitude = res.latitude
var longitude = res.longitude
console.log(res)
DB.add({//上传数据库
data:{
pola:latitude,
polong:longitude,
},
})
console.log("上传成功")
},//定位失败回调
fail: function() {
wx.hideLoading();
console.log("getLocationFail")
},
complete: function() {
//隐藏定位中信息进度
wx.hideLoading()
}
})
},
调了一下日志,发现真机调试1.0与2.0是有不同的。在2.0里面没有报错,只是单纯的获取地理位置失败,但是在1.0模式上面就有错误代码了。得在app.json里加上
"requiredPrivateInfos": ["getLocation", "chooseLocation"],
真机调试下看看日志 卡在哪里了 自己帮自己