[ECharts] There is a chart instance already initialized on the dom. 已存在图表,渲染重复

   报错:已存在图表,渲染重复

   解决:   在合适的时机执行 dispose 方法即可


//  echarts 全局存入 实例
let myChart: any;

// 在你的 initChart 初始化 Echarts 方法中 先执行清理方法
const initChart = () => {

 // 执行清理方法然后初始化
  if(myChart){
    console.log('存在则清空')
    myChart.dispose();
  }


  // 暂存 Echarts 实例 
  myChart = echarts.init(chartRef.value);

}

猜你喜欢

转载自blog.csdn.net/youyudehan/article/details/140730233