vue前端根据接口返回的url 下载图片

downloadPicture(imgSrc, name) {

const image = new Image();

// 解决跨域 Canvas 污染问题

image.setAttribute("crossOrigin", "anonymous");

image.src = imgSrc;

image.onload = () => {

const canvas = document.createElement("canvas");

canvas.width = image.width;

canvas.height = image.height;

const context = canvas.getContext("2d");

context.drawImage(image, 0, 0, image.width, image.height);

canvas.toBlob((blob) => {

const url = URL.createObjectURL(blob);

const a = document.createElement("a");

a.download = name || "photo";

a.href = url;

a.click();

a.remove();

URL.revokeObjectURL(url);

});

};

},

downLineFlow(row) {

this.downloadPicture(row.signatureUrl, row.username);

},

相关推荐
ch.ju2 分钟前
Java程序设计(第3版)第二章——java的数据类型:字符 char
java
尘世壹俗人2 分钟前
idea提交git版本由于中文文件名卡死不动
java·git·intellij-idea
木斯佳2 分钟前
前端八股文面经大全:腾讯前端一面(2026-04-04)·深度解析
前端·ai·鉴权·monorepo
帅小柏2 分钟前
VSCode Remote SSH 一直转圈连不上服务器?踩坑全记录
服务器·vscode
code_Bo4 分钟前
kiro生成小程序商业案例
前端·微信小程序·小程序·云开发
yellowbuff5 分钟前
为什么你的 0.01 秒倒计时看起来一卡一卡的?
前端
深挖派5 分钟前
IntelliJ IDEA 2026.1 安装配置与高效开发环境搭建 (保姆级图文教程)
java·ide·intellij-idea
TG_yunshuguoji5 分钟前
阿里云代理商:百炼大模型技术解析与应用指南
服务器·阿里云·云计算
人工小情绪8 分钟前
Linux下离线安装timm
linux·运维·服务器
onebyte8bits8 分钟前
NestJS 系列教程(十八):文件上传与对象存储架构(Multer + S3/OSS + 访问控制)
前端·架构·node.js·状态模式·nestjs