美文网首页
There is a chart instance alread

There is a chart instance alread

作者: krystal_H | 来源:发表于2022-09-05 09:49 被阅读0次

    定时刷新请求数据,或频繁切换回出现警告,表明DOM上已经初始化了一个图表实例
    解决:
    将初始化echart变量作为全局变量写在方法外,在初始化时先判断是否存在即可

    let chartDom = document.getElementById('xxx');
    if (myChart != null && myChart != "" && myChart != undefined) {
       myChart.dispose();
    }
    myChart = echarts.init(chartDom)
    

    相关文章

      网友评论

          本文标题:There is a chart instance alread

          本文链接:https://www.haomeiwen.com/subject/trpvnrtx.html