1***@qq.com
1***@qq.com
  • 发布:2022-05-25 17:31
  • 更新:2022-05-25 22:55
  • 阅读:172

getLocation 打包后获取不到

分类:uni-app
var currentWebview = this.$scope.$getAppWebview()   
            setTimeout(function() {  
                wv = currentWebview.children()[0]  

                let data = {  
                    a:11111111  
                }  
                let index = 1  
                setInterval(()=>{  

                    uni.getLocation({  
                        type: 'gcj02',  
                        success:  (res)=> {  
                            index = index + 1  
                            this.jingweidu =  res.longitude + ' ' + res.latitude  
                            let data = {  
                                lng:res.longitude,  
                                lat:res.latitude,  
                                index:index  
                            }  
                            currentWebview.children()[0].evalJS("alert('1')")  
                            // currentWebview.children()[0].evalJS("getData(21)")  
                            // currentWebview.children()[0].evalJS("getData(" + res.longitude + ",'" + res.latitude + "','" + index + "')")  
                        }  
                    });  
                },1000)  

            }, 1000); 

代码如上。
再标准基座调试的时候一切正常,
但是打包或者自定义基座的时候,连alert打印1都不出来

求教……


得,问题查明,不是evalJS有问题,是getLocation没有成功。这又是问什么呢

2022-05-25 17:31 负责人:无 分享
已邀请:
小枫叶

小枫叶 - 外包接单加v:wlmk1234567 注明来意

高德或者百度的key 以及定位的权限 等等 都检查一遍 剩下的把代码检查一遍

要回复问题请先登录注册