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

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

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

报错如下:


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

apicloud开发调试方法 nodejs [超低,超省内存占用] 兼容最新用友 you-cli

apicloud 开发 + 模拟器 +浏览器 +其它这些一开相当占用内存,让电脑不堪重负.于是我想到用命令行来实现调试这样可以不开启apicloud软件进行调试了 命令行+ 模拟器 就可以调试了准备1.检出项目.可以用svn检出,也可以直接…

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

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

[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 年底逐…

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

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

在CentOS 5.x 6.x里使用yum源 换阿里云国内源换vault.centos.org源

阿里云CentOS 5 的系统,无法用yum来安装应用软件。  原因:CentOS 5 在2017-03-31日已经结束支持,不再提供维护更新,所以包括阿里云镜像站的文件可能都是过时或已经有部分文件缺失。 &n…

Chrome 最全历史版本下载以及chromedriver下载

https://vikyd.github.io/download-chromium-history-version/#/ https://dl.lancdn.com/landian/soft/chrome/m/ chromedriver的版…

发表评论

访客

看不清,换一张

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