使用echarts时如何防止“There is a chart instance already initialized on the dom.”的警告

1,554 阅读1分钟

使用echarts时如何防止“There is a chart instance already initialized on the dom.”的警告。根据警告意思,显然是实例容器dom已经有一个echarts实例了,而echarts实例容器不能初始化多个echarts实例。

解决方法就是使用echarts.getInstanceByDom()方法获取dom容器上的实例,dispose(销毁实例 )它,再重新实例化。

我这里的实例代码如下图: