app.json中开启服务
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
WXML
<text bindtap="getWhere">获取位置</text>
WXJS
getWhere(){
wx.getLocation({
type: 'wgs84',
success (res) {
console.log(res)
const latitude = res.latitude
const longitude = res.longitude
const speed = res.speed
const accuracy = res.accuracy
}
})
},