腾讯WeMap-微信小程序-报错之getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json

文档:

https://lbs.qq.com/

复制代码
  wx.getLocation({
    type: 'wgs84',
    success(res) {
      console.log(res)
    },
    fail(res) {
      console.log(res) // getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json
    }
  })
复制代码

错误场景:在开发者工具中,是可以success的,但是在真机调试的时候,就会fail,原本考虑是,配置问题:

https://lbs.qq.com/faq/miniprogramFaq/wxJsSdk

 

 

 

 

但是查看了微信平台,已经配置过了

 

 

解决方案:

小程序app.json添加:

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

最主要的是红色的部分。

最终问题解决。

 参考:

https://blog.csdn.net/qq_40047019/article/details/125997964

posted @   最爱小虾  阅读(2581)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2019-09-26 根据 sitemap 的规则[0],当前页面 [pages/index/index] 将被索引
2017-09-26 运行npm install出现警告
点击右上角即可分享
微信分享提示