uniapp获取位置时显示getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json

发布时间 2023-08-07 17:32:17作者: 干红

uniapp获取位置时显示getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json

解决方式:1.manifest.json文件 "mp-weixin" 中添加

"permission" : {
"scope.userLocation" : {
"desc" : "小程序将使用定位功能"
}
},
"requiredPrivateInfos": [
"chooseAddress",
"chooseLocation",
"choosePoi",
"getLocation",
"onLocationChange",
"startLocationUpdateBackground",
"startLocationUpdate"
]