3***@qq.com
3***@qq.com
  • 发布:2025-06-26 23:20
  • 更新:2025-06-26 23:46
  • 阅读:64

我使用的是uni-app X app端 uni.getLocation 真机测试可以,但云打包后不执行,不报错 求解决

分类:uni-app x
        getCurrentLocation() {  
            uni.getLocation({  
                type: 'wgs84',  
                altitude: true,  
                isHighAccuracy: true,  
                success: (res) => {  // 使用箭头函数保持this指向  
                    this.latitude = res.latitude;  
                    this.longitude = res.longitude;  
                    this.provinceName = this.getProvinceByCoordinate(res.latitude, res.longitude);  
                    console.log('获取位置成功:', this.provinceName);  
                    // 确保获取到位置后再调用二维码接口  
                    this.fetchQRCode();  
                },  
                fail: (err) => {  
                    console.error('获取位置失败:', err);  
                    uni.hideLoading();  
                    uni.showToast({  
                        title: '获取位置失败',  
                        icon: 'none'  
                    });  
                }  
            });  
        },
2025-06-26 23:20 负责人:无 分享
已邀请:
DCloud_heavensoft

DCloud_heavensoft

wgs84也就是系统定位,不涉及三方SDK。
你是同一台手机吗,比较老的安卓手机,系统定位是拿不到的,因为它连了谷歌的服务,需要翻墙。
然后检查一下权限,是不是没有开定位权限

要回复问题请先登录注册