文
章
目
录
章
目
录
在使用echarts绘制图表时,出现如下报错,导致图表无法绘制出来:
[ECharts] 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.
原因
原因很简单,就是获取不到绘制存放图表的容器的宽度和高度。
解决办法
给绘制存放图表的容器设置宽高就可以了,比如:
<div id="chart" style="width:100px;height:100px"></div>
然后再去运行就可以正常绘制出echarts图表了。