y***@163.com
y***@163.com
  • 发布:2022-08-23 10:53
  • 更新:2022-08-26 20:11
  • 阅读:556

继续uni入坑,地图问题,uni真的不靠谱,坑太多

分类:uni-app
<map v-if="showMap" id="map1" show-location ref="map1"   
        :latitude="latitude"   
        :longitude="longitude"  
        :circles="circles"  
        scale="10"  
         style="width: 750rpx; " :style="{height:windowHeight+'px'}"></map>
created() {  
            //获取手机信息  
            uni.getSystemInfo({  
                success:  (res) =>{  
                    this.windowHeight=res.windowHeight  

                }  
            });  
            map=uni.createMapContext('map1',this)  
            uni.getLocation({  
                geocode:true,  
                type: 'wgs84',  
                success:(res)=>{  
                    console.log(res)  
                    this.latitude=res.latitude  
                    this.longitude=res.longitude  
                    this.address=res.address.city  
                    if(this.longitude!==0){  
                        this.showMap=true  
                    }  

                }  
            })  
        }

地图大小不对,报错ReferenceError: map is not defined

2022-08-23 10:53 负责人:DCloud_UNI_Anne 分享
已邀请:
y***@163.com

y***@163.com (作者) - 臭屌丝

已经var map报错

a***@gmail.com

a***@gmail.com

如果自己有高级应用,可以用原生插件。

zhangrl

zhangrl

map=uni.createMapContext('map1',this) 这个 onready 执行呢

CODE_XU

CODE_XU

在页面中,必须在 onReady 中调用。
在组件中,必须在 mounted 中调用。

3***@qq.com

3***@qq.com - 前端开发

请查看声明周期onReady vue环境也会用nextTick解决 这个和bug无关

j***@126.com

j***@126.com

再想想…

j***@126.com

j***@126.com

再想想…

j***@126.com

j***@126.com

再想想…

该问题目前已经被锁定, 无法添加新回复