普通a链接点击下载(同源)
<a href="http://ppt.beegoedu.com/Upload/unlogo/2017112980744.jpg" download="11.jpg">111</a>
跨域下载文件(非同源)
<a onclick="a()">下载图片</a>
function a(){
let url ="http://ppt.beegoedu.com/Upload/unlogo/2017112980744.jpg";
let name ="123";
const downloadRes = async () => {
let response = await fetch(url);
let blob = await response.blob();
let objectUrl = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = objectUrl;
a.download = name;
a.click()
a.remove();
}
downloadRes();
}