echarts 报错 should not be called during main process

原因是,在循环渲染多个图表的时候,渲染的图表和数据有先后顺序,有时候出现对应不上的情况,可能是数据已经好了,图表要渲染慢一些

导致这个问题

解决就是,放在定时器中,比如,我这个是在渲染之后,进行resize,那么就需要将option和resize放在一个定时器中,保持在同一个队列

 chartInit(chart) {
      let this_ = this;
      if(this.chart){
        this.chart.clear();
      }else{
        this.chart = this.$refs.chart;
      }; 
     
      // must resize chart in nextTick
      this.$nextTick(() => {
        setTimeout(()=>{
          this_.options = ChartConfig(this_.chartData,this_.chartType);
          this_.resizeChart();
        },300);
      });
 },

resizeChart() {
      this.chart && this.chart.resize();
},
原文地址:https://www.cnblogs.com/fyjz/p/14578170.html