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

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

2024-11-10 09:11:15 前端知识 前端哥 489 72 我要收藏

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

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


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

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

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


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

}

转载请注明出处或者链接地址:https://www.qianduange.cn//article/20129.html
标签
评论
发布的文章

前端:HTML

2025-02-23 11:02:50

CSS3快速入门

2025-02-23 11:02:48

CSS3——transform属性

2025-02-23 11:02:46

React【vite使用模块化css】

2025-02-23 11:02:44

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!