【踩坑记录】微信开发者工具已授权位置getLocation时却显示未授权 |
您所在的位置:网站首页 › 微信小程序获取定位失败怎么办 › 【踩坑记录】微信开发者工具已授权位置getLocation时却显示未授权 |
前提:uniapp的wx小程序项目,接手别人的老项目,getLocation时开发者工具报未授权,顺着授权步骤走却发现已经授权了。已经上线的小程序没问题。遇到有段时间了,今天有时间看看:
如上图:明明已经授权了 排查流程: 1.uni.authorize()查询是否已授权 uni.authorize({ scope:'scope.userLocation', success: (res) => { console.log('authorize=>success:',res); }, fail: (err) => { console.log('authorize=>fail:',fail); } },)结果: 2.查看getLocation()的报错信息 uni.getLocation({ type: 'wgs84', success: function(result) { successBack(result) }, fail: function(error) { console.log('getLocation=>fail:',error); 。。。。。。。。。 }结果: 需要在requiredPrivateInfos字段中声明 百度报错信息得知:地理位置接口新增与相关流程调整 | 微信开放社区 (qq.com) 新的接口除了要申请接口外还要在uniapp的manifest.json中配置 (55条消息) 解决小程序报错getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json_tony康的博客-CSDN博客加上后 "permission" : { "scope.userLocation" : { "desc" : "你的位置信息将用于小程序位置接口的效果展示" } }, "requiredPrivateInfos":["getLocation"],就可以了 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |