
官网wx.getLocation(Object object)

代码展示:

const address=reactive()
onLoad(){
getLocate()
}
const getLocate=()=>{
uni.getLocation({
success: (res) => {
uni.request({
header: {"Content-Type": "application/text"},
url: '接口?location=' + res.latitude +',' +
res.longitude + '&key=腾讯地图key/高度地图key',
success(resMap) {
if (resMap.code === 200) {
let obj = {
city:resMap.address,
lng: res.longitude,
lat: res.latitude
}
address = obj
uni.setStorageSync('address', address)
}
}
})
},
fail() {
uni.showToast({
icon: 'none',
title: "请打开定位权限后重试"
})
}
});
}