// chart 图
<v-chart
ref="saleStRef"
:options="options"
autoresize
style="width: 100%; height: 100%"
/>
// 按钮
<el-button
type="primary"
size="mini"
@click="exportPng('saleStRef', 'name')"
>
导出
</el-button>
导出方法
// 自定义导出方法
exportPng(ref, title) {
let picInfo = this.$refs[ref].getDataURL({
type: "png",
pixelRatio: 4
});
let elink = document.createElement("a");
elink.download = title;
elink.style.display = "none";
elink.href = picInfo;
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
}