axios({
method: 'get',
url: music.value,
responseType: 'blob',
}).then((res) => {
if (!res) {
return
}
let blobUrl = window.URL.createObjectURL(res.data);
let link = document.createElement('a');
document.body.appendChild(link);
link.style.display = 'none';
link.href = blobUrl;
link.download = music.name;
// 自触发click事件
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(blobUrl);
})
不需要后端修改求情头协议