赞
踩
getLocation() {
wx.getLocation({
type: 'wgs84',
success: (res) => {
console.log(res)
this.setData({
longitude: res.longitude,
latitude: res.latitude
})
},
fail: (err) => {
console.log(err)
}
})
}
会报错:getLocation:fail require permission desc
需要在小程序配置文件(app.json)中添加以下内容:
"permission" : {
"scope.userLocation" : {
"desc" : "你的位置将用于小程序接口的效果展示"
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。