chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js

今天用uniapp调用用户地址时,发现了一个错误:

chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js_第1张图片

chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js_第2张图片

  • 1、微信小程序 调用

后面发现,自 2022 年 7 月 14 日起,开发者在使用地理位置相关接口时,需要提前在 app.json 中进行配置。 

网址:地理位置接口新增与相关流程调整 | 微信开放社区 (qq.com)

 开发者均需要在 app.json 中 requiredPrivateInfos 配置项中声明,

app.json 里面

"requiredPrivateInfos" : [ 
    "chooseAddress" 
]

chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js_第3张图片

  • 2、uniapp 调用 

其他配置:uni.chooseAddress(OBJECT) | uni-app官网 (dcloud.net.cn)

  1. 打开 manifest.json 选择 源码视图,
  2. 找到mp-weixin节点,添加requiredPrivateInfos的配置
"mp-weixin": {
    "requiredPrivateInfos": [
      "chooseAddress"
    ],
}

chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js_第4张图片

  • 3、调用成功后的结果页面

 调用成功后,会出现下面的页面。

chooseAddress:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.js_第5张图片 

你可能感兴趣的:(uniapp,前端开发错误聚集,微信小程序,json)