解决小程序报错 getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json

发布时间 2023-08-18 13:19:14作者: 贲风

一、unipp项目

打开uniapp项目的配置文件manifest.json,选择“源码视图”。

/* 小程序特有相关 */

"mp-weixin": {
    "appid": "你的开发者id",
    "setting": {
        "urlCheck": true,
        "es6": true,
        "postcss": true,
        "minified": true
    },
    "usingComponents": true,
    "permission": {
        "scope.userLocation": {
            "desc": "你的位置信息将用于小程序位置接口的效果展示"
        }
    },
    "requiredPrivateInfos": [
        "getLocation"
    ]
},