There is a chart instance already initialized on the dom!警告
Posted shuilangyizu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了There is a chart instance already initialized on the dom!警告相关的知识,希望对你有一定的参考价值。
使用Echarts插件的时候,多次加载会出现There is a chart instance already initialized on the dom.这个错误,改插件已经加载完成。
并且如果你图表中定义了点击方法,多次覆盖之后,点击方法会触发多次
解决方法:
在方法最外层定义全局变量
var myCharts;
然后在插件使用方法中:
if (myChart != null && myChart != "" && myChart != undefined){ myChart.dispose(); } // 基于准备好的dom,初始化echarts实例 myChart = echarts.init(document.getElementById(‘sjtjt‘));
方法的最开始写上判断,然后初始化echarts实例;
最重要的就是全局定义和方法开头的判断然后
myChart.dispose();
以上是关于There is a chart instance already initialized on the dom!警告的主要内容,如果未能解决你的问题,请参考以下文章
Is there a difference between `==` and `is` in Python?
There was a problem with the instance info replicator
UVA10462:Is There A Second Way Left? (判断次小生成树)
Spirng 循环依赖报错:Is there an unresolvable circular reference?
npm报错This is probably not a problem with npm. There is likely additional logging
人工智能有简单的算法吗?Appendix: Is there a simple algorithm for intelligence?