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

问题描述

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


解决方案:

需要在manifest.json文件中配置requiredPrivateInfos属性:
uni微信小程序地理定位报错:getLocation:fail the api need to be declared in the requiredPrivateInfos field in app_第1张图片

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

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

你可能感兴趣的:(ERR,配置文件,微信小程序,微信小程序,小程序,uni-app)