强制下载图片
function downloadImg(imgsrc, name) {
const image = new Image();
image.src = imgsrc;
image.setAttribute('crossOrigin', 'anonymous');
image.onload = function () {
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);
const url = canvas.toDataURL('image/png');
const a = document.createElement('a');
a.download = name;
a.href = url;
a.click();
};
}