There is a chart instance already initialized on the dom

来源:互联网 发布:centos mysql启动失败 编辑:程序博客网 时间:2024/06/06 01:30

使用Echarts插件的时候,多次加载会出现There is a chart instance already initialized on the dom.这个错误,改插件已经加载完成。

解决方法:

在方法最外层定义全局变量

var myChart;

然后在插件使用方法中:

 if (myChart != null && myChart != "" && myChart != undefined) {        myChart.dispose();    }// 基于准备好的dom,初始化echarts实例     myChart = echarts.init(document.getElementById('sjtjt'));


方法的最开始写上判断,然后初始化echarts实例;

最重要的就是全局定义和方法开头的判断然后

myChart.dispose();
!!!!!!

阅读全文
1 0