1、当一个页面只有一个echarts图形时,可以写为如下代码:
myChart.setOption(option);
window.onresize = myChart.resize;
2、当一个页面含有多个echarts图形时,可以写成如下代码:
myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); });
当页面中包含多个div和echart时,如果写成第一种情况代码时,只有最后一个被画出的图形能自适应屏幕大小,建议全部使用第二种情况。