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

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

admin4年前 (2022-11-07)技术分享7130

报错如下:


"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” 的相关文章

php高效检测远程图片是否存在

php高效检测远程图片是否存在function img_exits($url){     $ch = curl_init();    &…

解决 SVN Skipped 'xxx' -- Node remains in conflict

更新命令:svn up提示代码:意思就是说 ,这个文件冲突了,你要解决下Updating '.': Skipped 'data/config.php' -- …

用CMD命令查询域名的DNS解析记录:A,NS,MX,CNAME,TXT

1、查询域名的A记录nslookup -qt=A bitefu.net当然查询A记录你直接用ping命令来ping域名也可以获得A记录。2、查询域名的NS记录nslookup -qt=NS bitefu.net3、查询域名的MX记录nslo…

全世界最快dns分享 Public DNS Server List

偶然发现一个共享全世界最快dns的网站,当然也包含中国了https://public-dns.info/ 中国https://public-dns.info/nameserver/cn.html…

redis 设置过期Key 的 maxmemory-policy 六种方式

平时会用到redis 当缓存过多时会遇到下面的报错OOM command not allowed when used memory > 'maxmemory'这说明redis的缓存满了我们可以通过修改过期策略来修改cd…

TeraCloud:日本免费15G网盘,支持WebDav。适合搭配Zotero,AirExplorer实现自动同步备份

TeraCloud:日本免费15G网盘,支持WebDav。适合搭配Zotero,AirExplorer实现自动同步备份

TeraCloud是日本老牌网盘,速度挺快的。注册之后输入邀请码:“SX3BY”还可获得额外的5 GB.(如果你不输入邀请码,只能有10G)。经过我自己的尝试,我发现windows自带的资源管理器同步并不好,推荐Teracloud推荐的一些…

发表评论

访客

看不清,换一张

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