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);

},

相关推荐
云创智城-yuncitys5 分钟前
YunParking 4.0:JDK 17 与 Spring Boot 3.2 的停车云升级
java·开发语言·spring boot
文丑颜不良啊6 分钟前
LeetCode1661~1680题目解析
java·leetcode
风骏时光牛马8 分钟前
生成一个后端标题,只需要一个标题,不需要其他的任何文本。
前端
子非鱼@Itfuture8 分钟前
关于前后端联调中登录状态/登录信息失效?
java·前端
郭小李9 分钟前
openFeign入门
java·开发语言·前端
wacsii16 分钟前
【Linux进程(一)】Linux 进程初探:操作系统如何管理进程?fork() 为什么返回两次?
linux·运维·服务器
馒头不想说话18 分钟前
AI当运营,帮你省人力
前端
共享家952719 分钟前
408 操作系统第一章
服务器·数据库·windows
wljt34 分钟前
公司二-面试题
java·开发语言·mybatis
梦曦i36 分钟前
uni-app x下自研架构的工程化突围
前端·架构·uni-app x