parent
fd319de460
commit
7425a25bd5
@ -0,0 +1,45 @@ |
|||||||
|
<template> |
||||||
|
<view> |
||||||
|
<view class="location"> |
||||||
|
<view>经度:{{longitude}}</view> |
||||||
|
<view>纬度:{{latitude}}</view> |
||||||
|
</view> |
||||||
|
<button class="center-btn" @click="showMeLocation">我在哪</button> |
||||||
|
</view> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
data() { |
||||||
|
return { |
||||||
|
longitude:'', |
||||||
|
latitude:'' |
||||||
|
} |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
showMeLocation(){ |
||||||
|
let this_ = this; |
||||||
|
uni.getLocation({ |
||||||
|
type: 'gcj02', |
||||||
|
success: function (res) { |
||||||
|
console.log('当前位置的经度:' + res.longitude); |
||||||
|
console.log('当前位置的纬度:' + res.latitude); |
||||||
|
this_.longitude = res.longitude; |
||||||
|
this_.latitude = res.latitude; |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style lang="scss" scoped> |
||||||
|
.location{ |
||||||
|
padding: 40rpx; |
||||||
|
margin: 50rpx 20rpx; |
||||||
|
background-color: #eee; |
||||||
|
} |
||||||
|
.center-btn{ |
||||||
|
margin: 0 50rpx; |
||||||
|
} |
||||||
|
</style> |
Loading…
Reference in new issue