echarts--onresize adaptive width needs to be refreshed to adapt to the problem

Replace window.onresize with window.addEventListener to solve the problem

//需要刷新才能适配
  window.onresize = function () {
    
    
    //自适应大小
    chart.resize();
  };
//不需要刷新,动态适配宽度
  window.addEventListener("resize", () => {
    
    
    //图表响应处理
    chart.resize();
  });

Guess you like

Origin blog.csdn.net/weixin_45288172/article/details/130702342