123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <template>
- <view>
- <u-form-item label="地址" borderBottom prop="pos_name">
- <u-input :border="border" v-model="pos_name" type="textarea"></u-input>
- <u-button slot="right" type="primary" size="medium" @click="getAddress"
- class="form-inner-btn">获取定位
- </u-button>
- </u-form-item>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- pos_name: '',
- latitude: '',
- longitude: '',
- address: ''
- }
- },
- methods: {
- //获取定位信息
- getAddress() {
- uni.chooseLocation({
- success: res => {
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
- this.pos_name = res.name;
- this.latitude = res.latitude;
- this.longitude = res.longitude;
- this.address = res.address
- }
- });
- },
- }
- }
- </script>
- <style scoped>
- #container {
- width: 100%;
- height: 100vh;
- }
- </style>
|