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

在uniapp微信小程序中使用getLocation时,出现报错

 {errMsg: "getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json"}

这时,先检查manifast.json中mp-weixin是否含有以下字段

     "permission" : {
            "scope.userLocation" : {
                "desc" : "为了您更好的体验,请确认获取您的位置"
            }
        },
        "requiredPrivateInfos" : [ "getLocation" ],

 如果已经设置仍然报错开头信息,请检查微信开发者调试及出库版本(2.6.0以上版本无法使用,将版本降到2.25.4)这时就可以获取到定位信息

猜你喜欢

转载自blog.csdn.net/m0_68812159/article/details/127813923