uni-app微信小程序getLocation获取定位相关配置
1、在uni-app的manifest.json添加下面两句:
"mp-weixin" : { "appid" : "", "requiredPrivateInfos": [ "getLocation" ], "permission" : { "scope.userLocation" : { "desc" : "你的位置将用于小程序接口的效果展示" } } },
或者在manifest.json的视图上勾选位置接口:
当然:
"requiredPrivateInfos": [ "getLocation" ],
还是要手动添加上,如果缺少requiredPrivateInfos的getLocation,则会报错:
getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json
如果缺少permission的scope.userLocation,则会报错:
getLocation:fail require permission desc
上面都添加了,uni-app会自动在小程序的app.json加入下面的配置: