错误信息:
原因:
这个api 需要在app.json的requiredPrivateInfos字段中声明
解决方案:
方案一:uniapp项目
1. 打开uniapp项目的配置文件manifest.json,选择“源码视图”。
2. 添加requiredPrivateInfos字段
配置代码如下:
"mp-weixin": {
"appid": "你的开发者id",
"usingComponents": true,
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos": ["chooseLocation", "getLocation"]
方案二:微信小程序原生开发
打开项目的配置文件app.json。
{
"pages": ["pages/index/index"],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
},
},
"requiredPrivateInfos": ["chooseLocation", "getLocation"]
}
requiredPrivateInfos的配置扩展:
注:模糊位置信息api和精确位置信息api是互斥的. 如:getLocation 和getFuzzyLocation 同时写时,就会报错