// imgUrl 传入要下载的图片链接,imgName 可以自行命名下载图片名称
fetch(imgUrl).then(function(res) {
res.blob().then(function(blob) {
var a = document.createElement('a');
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = imgName;
a.click();
window.URL.revokeObjectURL(url);
})
}).catch(function(error) {
window.open(imgUrl);
});