<template> <div> <div ref="wordcloud" class="wordcloud"> </div> <button @click="download">下载</button> </div> </template>
下载方法如下:
download(){ let mycanvas=document.getElementsByTagName('canvas')[0] let image=mycanvas.toDataURL("image/png"); let $a = document.createElement('a'); $a.setAttribute("href", image); $a.setAttribute("download", "echarts图片下载.png"); $a.click(); }