岄. 2024-06-18 13:33 采纳率: 91.7%
浏览 2
已结题

(标签-git|关键词-app)


        <button @click="goJ">点击获取经纬度</button>
        <p>经度{{latitude}}</p>
        <p>纬度{{longitude}}</p>

        methods: {
            goJ() {
                let that = this
                console.log(2);
                uni.getLocation({
                    type: 'wgs84',
                    enableHighAccuracy: true,
                    success: function(res) {
                        console.log('当前位置的经度:' + res.longitude);
                        console.log('当前位置的纬度:' + res.latitude);
                        that.latitude = res.latitude
                        that.longitude = res.longitude
                        console.log(that.latitude, 'oo');
                        uni.showToast({
                            title: '成功',
                            icon: 'success'
                        });
                    },
                    fail: err => {
                        uni.showToast({
                            title: err.errMsg,
                            icon: 'error'
                        });
                    }
                });

            }
        }

uniapp求当前位置的经纬度。我这么写,然后在手机自带的浏览器上可以获取到经纬度,但是手机上的其他浏览器类似火狐浏览器不能获取到经纬度。然后我在PC端运行,除了谷歌浏览器不能运行,Edge和火狐可以运行获取到经纬度

  • 写回答

2条回答 默认 最新

  • 岄. 2024-06-21 15:38
    关注

    没有答案

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月21日
  • 已采纳回答 6月21日
  • 创建了问题 6月18日