js图片不打开直接下载(文件下载)

fetch(放要下载的url).then(async res => await res.blob()).then((blob) => {

   const a = document.createElement('a');

   a.style.display = 'none';

   a.href = URL.createObjectURL(blob);

   a.download = 放要下载的名字;

   document.body.appendChild(a);

   a.click();

   document.body.removeChild(a);

})

上一篇:Android开发2——创建测试项目


下一篇:android git上开源的项目收藏