问题描述
报错: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"] },
参考文档:官方文档
需要注意的是:声明了模糊位置信息就无法声明精确位置信息