1.动态循环id

<div v-for="(item,index) in chartList" :key="index">
  <div :></div>
</div>

2.js部分

this.chartList = res.data.data.chartList;//从后台获取数据
if (this.chartList.length > 0) {
  this.$nextTick(() => {
    this.initChart()
  })
}
initChart() {
    this.chartList.forEach((val, index) => {
      const myChart = this.$echarts.init( document.getElementById(`chart${index}`))
      //注意this.chartList[index]这是我们后台拼好数据直接set就行了
      myChart.setOption(this.chartList[index])
    })
  }
},

参考于:https://www.jianshu.com/p/a7af5814efd9

相关文章:

  • 2021-12-31
  • 2022-01-23
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2021-06-11
  • 2021-10-14
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案