const downloadRes = async (url, name) => { 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; document.body.appendChild(a); a.click(); setTimeout(function () { document.body.removeChild(a); }, 1000); }; downloadRes('文件url', '文件名');