<template>
<view>
<button @click="goPage">跳转页面</button>
</view>
</template>
<script>
export default {
data() {
return {
watchlocationId: null,
}
},
onShow() {
if (this.watchlocationId == null) {
this.watchLocation()
}
},
onUnload() {
if (this.watchlocationId) {
plus.geolocation.clearWatch(this.watchlocationId);
this.watchlocationId = null
}
},
methods: {
// 高精度监听位置
watchLocation() {
let _this = this
let time = new Date().valueOf()
this.watchlocationId = plus.geolocation.watchPosition(function(position) {
console.log(position);
})
},
goPage(){
uni.reLaunch({
url:"/pages/index/index"
})
}
}
}
</script>
<style></style>
0 个回复