js实现图片自动下载
1.添加img标签
<img id='downImg' src='' style='display: none;' />
2.调用方法download
//图片路径
var src = './1.png';
//下载保存文件名
var imgname = 'testImg.jpg';
function download(src,imgname) {
$('#downImg').attr('src', src);
var img = $('#downImg').attr("src");
var alink = document.createElement("a");
alink.href = img;
alink.download = imgname;
alink.click();
}