使用echarts插件,多次加载出现There is a chart instance already initialized on the dom,报的警告,看不下去啦

解决方法:

在data()定义全局变量

data(){
  return{
    chart: null
  }
}

在使用插件方法中最前面添加

if (this.chart != null && this.chart != "" && this.chart != undefined) {
  this.chart.dispose();
}

然后在实例化

this.chart  = echarts.init(document.getElementById('#id'));

posted @ 2021-07-15 10:32  wpTing  阅读(157)  评论(0编辑  收藏  举报