There is a chart instance already initialized on the dom

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

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

你可能感兴趣的:(There is a chart instance already initialized on the dom)