自定义echarts的下载事件 (按钮
+ 事件
)
<div ref="circleChart" id="circleChart"></div>
<a :href="chartImgUrl" download="echart.png" @click="handleChartDownload">
下载
</a>
handleChartDownload() {
let myChart = this.$echarts.init(this.$refs.circleChart)
let that = this
setTimeout(function() {
that.chartImgUrl = myChart.getDataURL({
pixelRatio: 2, // 解决模糊
backgroundColor: '#fff'
});
}, 100)
},