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

},

相关推荐
bloglin999994 小时前
scp、rsync远程文件同步
linux·运维·服务器
迦南的迦 亚索的索4 小时前
LINUX环境
linux·运维·服务器
yuanjj884 小时前
linux下调试域格CLM920 NC5等9x07平台模块 QMI拨号
linux·运维·服务器
懂懂tty4 小时前
React状态更新流程
前端·react.js
IMPYLH4 小时前
Linux 的 printenv 命令
linux·运维·服务器·bash
SilentSamsara4 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
小码哥_常4 小时前
告别繁琐!手把手教你封装超实用Android原生Adapter基类
前端
HoneyMoose5 小时前
Jenkins Cloudflare 部署提示错误
java·servlet·jenkins
阿丰资源5 小时前
基于SpringBoot的物流信息管理系统设计与实现(附资料)
java·spring boot·后端
skywalk81635 小时前
pytest测试的时候这是什么意思?Migrating <class ‘kotti.resources.File‘>
前端·python