uni微信小程序地理定位报错:getLocation:fail the api need to be declared in the requiredPrivateInfos field in app

文章来源:CSDN 发布日期:2024-04-16 分类:小程序博客 阅读( )

问题描述

报错:errinfo {“errCode”: “0”, “errMsg”: “getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json”}


解决方案:

需要在manifest.json文件中配置requiredPrivateInfos属性:
在这里插入图片描述

 /* 小程序特有相关 */  "mp-weixin": {    "appid": "wx7537c85ad8296fa3",    "setting": {      "urlCheck": false,      "minified": true,      "es6": true    },    "usingComponents": true,    "permission": {      "scope.userLocation": {        "desc": "为了方便用户选择起始地和目的地"      }    },    "requiredPrivateInfos": ["getLocation", "chooseAddress", "chooseLocation", "choosePoi", "onLocationChange"]  },

参考文档:官方文档
需要注意的是:声明了模糊位置信息就无法声明精确位置信息

最新文章:

二维码