1、首先需要在app.json中配置
app.json文件
"permission": {
"scope.userLocation": {
"desc": "您的位置信息用于获取当前定位地点" // 提示的文字,可自行定义
}
js文件
onReady: function () {
const that = this
wx.getLocation({
type: 'wgs84',
success(res) {
that.setData({
latitude: res.latitude,
longitude: res.longitude
})
},
fail(res) {
that.setData({
not_auth: true
})
}
})
}