用echarts实现展示地图,但是地图显示的范围一直超出他那个div,同时报错。
完整报错信息:
Can’t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.
按照网上的方法加上style="width=200px;height=200px;"还是不行,写在window.onload里也不行,还是dom没加载,所以写上延迟:

setTimeout(MapChartInit, 1000)

这个时候好像没有报错了,但是还是超范围
F12看生成的元素可以发现position: absolute,所以问题在于容器div的position是static所以找不到,改成position: relative就能正常显示了。
调了两天,最后发现有个功能Echarts不支持,还是去写百度地图API了,气出高血压。

 posted on 2022-05-18 10:50  15101051  阅读(7036)  评论(2编辑  收藏  举报