效果图:
注意:这里有个问题,就是这个经纬度必须在最开始的时候就指定,后面如果动态地修改经纬度是定位不了的。不过问题不大,以后我们使用的时候直接指定默认的地点就行。这个demo里面另外还自带了定位功能,在右下角
实现代码:
<template>
<view>
经度:
<uni-easyinput v-model="longitude" />
纬度:
<uni-easyinput v-model="latitude" />
<button type="primary" @click="openLocation()">查看位置</button>
</view>
</template>
<script>
export default {
data() {
return {
longitude: 116.39747,
latitude: 39.9085
};
},
methods: {
openLocation() {
uni.openLocation({
longitude: this.longitude,
latitude: this.latitude
});
}
}
};
</script>