使用api示例没效果
uni.getLocation({
type:'wgs84',
success:function(res){
console.log('当前位置的经度:'+ res.longitude);
console.log('当前位置的纬度:'+ res.latitude);
}});
要在Hbuilder搭建的项目上面的manifest.json文件下面的 源码视图 配置一段
注意!!! 如果是微信小程序的话
要在“mp-weixin”下面配置
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
}
还要配置一个
"requiredPrivateInfos": [
"getLocation"
]
为什么要配置这个呢 就是因为你不配置这个的话他会一直获取地理位置失败!!!!
希望能帮到你们 这是我的见解 谢谢!