getLocation 需要在 app.json 中声明 Permission 字段

小程序开发中,清除授权状态后,重新编译,提示:getLocation 需要在 app.json 中声明 Permission 字段

需要在 app.json 里面增加 permission 属性配置(小游戏需在game.json中配置):

  "permission": {
    "scope.userLocation": {
      "desc": "你的位置信息将用于小程序位置接口的效果展示"
    }
  },

效果:

 

确定之后即可授权。

原文地址:https://www.cnblogs.com/zjfjava/p/10953046.html