当前位置:首页 > 技术分享

解决小程序报错getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json

admin3年前 (2022-11-07)技术分享6534

报错如下:


"getLocation:fail the api need to be declared in the requiredPrivateInfos fi


解决方案:


一、unipp项目


打开uniapp项目的配置文件manifest.json,选择“源码视图”。


/* 小程序特有相关 */

"mp-weixin": {
	"appid": "你的开发者id",
	"setting": {
		"urlCheck": true,
		"es6": true,
		"postcss": true,
		"minified": true
	},
	"usingComponents": true,
	"permission": {
		"scope.userLocation": {
			"desc": "你的位置信息将用于小程序位置接口的效果展示"
		}
	},
	"requiredPrivateInfos": [
		"getLocation"
	]
},

二、原生小程序


打开项目的配置文件app.json。

{
    "pages": ["pages/index/index"],
    "permission": {
        "scope.userLocation": {
            "desc": "你的位置信息将用于小程序位置接口的效果展示" // 高速公路行驶持续后台定位
        }
    },
    "requiredPrivateInfos": [
		"getLocation"
	]
}

requiredPrivateInfos的配置扩展: 


表1中模糊位置信息(序号1)和精确位置信息(序号2-5)是互斥的,即声明了模糊位置信息就无法声明精确位置信息。


若同时声明模糊位置信息和精确位置信息,则在编译代码时出现错误;


更多文档,请参考官方文档:地理位置接口新增与相关流程调整 

扫描二维码推送至手机访问。

版权声明:本文由小刚刚技术博客发布,如需转载请注明出处。

本文链接:https://blog.bitefu.net/post/446.html

分享给朋友:

“解决小程序报错getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json” 的相关文章

百度云,天翼云盘解析网页地址 收集分享

百度云解析http://p.106666.xyz/https://pan.kdbaidu.com/https://pan.kdpd.me/https://yun.kdbaidu.com/http://blog.xxatf.top/https…

[Windows] Adobe Flash Player 34.0.0.92及可用版修改方法

[Windows] Adobe Flash Player 34.0.0.92及可用版修改方法

随着 2021 年的到来,Adobe Flash Player 也迎来了告别,Adobe 在 2020 年 12 月 31 日后将不再支持 Flash Player。其实早在 2017 年,Adobe 公司就已宣布,计划在 2020 年底逐…

php Aes 加密模式ECB填充pkcs5padding base64

最近做支付项目用到了aes加密不过试了好多办法总是和官方给出的结果不一样,找了很久终于找到了测试结果同 http://tool.chacuo.net/cryptaes/ <?php /**  * [Aes&nb…

七牛html js上传带进度条源码

七牛html js上传带进度条源码注册链接https://s.qiniu.com/uM7RJv完整代码下载:https://n802.com/f/349707-489018989-c141f6(访问密码:5036)http://www.yi…

百度云网盘高速下载方法[测试可用]

百度云网盘高速下载方法[测试可用]

大前提这是一个油猴脚本,安装脚本之前,必须先安装油猴浏览器扩展(如已安装则跳过):【第一步】下载油猴 --> 如有提示安装,则直接安装即可,否则继续执行第二步【第二步】安装油猴 --> 参考其中章节:&nbs…

apicloud影视APP源码 无需后台

apicloud影视APP源码 无需后台

介绍集合vip影视接口到一个android app中 方便观看各平台影视资源及直播开源地址:https://gitee.com/web/vip_yingshi软件架构使用apicloud搭建影视APP源码,无后台,调用接口同步api解析网址…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。