echarts提示Can’t get DOM width or height解决办法

前端 潘老师 7个月前 (10-19) 168 ℃ (0) 扫码查看



在使用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图表了。


版权声明:本站文章,如无说明,均为本站原创,转载请注明文章来源。如有侵权,请联系博主删除。
本文链接:https://www.panziye.com/front/9856.html
喜欢 (0)
请潘老师喝杯Coffee吧!】
分享 (0)
用户头像
发表我的评论
取消评论
表情 贴图 签到 代码

Hi,您需要填写昵称和邮箱!

  • 昵称【必填】
  • 邮箱【必填】
  • 网址【可选】