编程知识 cdmana.com

The same page of Vue refers to the encapsulated echarts component several times

We're encapsulating it echarts After component , When you need to introduce multiple times in the same page , There will be data coverage ,id It can't be reused

resolvent :
First turn on the id Delete , add to ref attribute

<div class="bar" ref="bar"></div>

And then modify js:

The initial release :

this.barCharts = echarts.init(document.getElementById("bar"));

After modification :

this.barCharts  = echarts.init(this.$refs.bar);

solve !

版权声明
本文为[CcChan]所创,转载请带上原文链接,感谢

Scroll to Top