Echarts通过v-if来控制切换时,templateA切换到templateB的时候templateA的图表会出现在templateB页面上,此时给templateA的div上添加key属性就可以解决了
<div ref="chart" key="myCharts" style="width: 100%; min-height: 500px;margin: auto;"></div>
当Echarts中的数据为活数据时,需要给Echarts函数套上$nextTick方法来实现,并加上延时器
this.$nextTick(()=>{
setTimeout(()=>{
this.createdEcharts(this.name,this.count)//Echarts函数
},3000)
})