<div @click="generateExcel(errurl)">点击下载</div>
export default {
name: "home",
components: {},
data() {
return {
errurl: "data:image/png;base64,iVBORw0KGgoxxxxx"
};
},
methods: {
generateExcel(errurl) {
const htmlContent = `
<html>
<head>
<title>Excel with Image</title>
</head>
<body>
<img src="data:image/png;base64,${errurl}" alt="image">
</body>
</html>
`;
const blob = new Blob([htmlContent], { type: 'application/vnd.ms-excel' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'excel_with_image.xlsx';
link.click();
URL.revokeObjectURL(url);
},
},
};