目录
- 一、出现场景
- 二、具体使用
一、出现场景
在项目的开发中,会出现打卡、定位当前位置的功能,那我们如何获取当前位置呢?这就需要使用getLocation
来获取当前位置坐标
二、具体使用
uni.getLocation({type: 'wgs84', // 返回可以用于uni.openLocation的经纬度success: function (res) {let longitude = res.longitude; // 经度let latitude = res.latitude; // 纬度console.log(longitude, latitude)},fail: function (err) {console.log('获取失败')}
});