1 axios({ 2 method: ‘get‘, 3 url: url, 4 responseType: ‘arraybuffer‘ 5 }).then( res=>{ 6 // console.log(res) 7 let blob = new Blob([res],{type: ‘image/jpg‘}) 8 let objectUrl = URL.createObjectURL(blob) 9 let a = document.createElement(‘a‘); 10 document.body.appendChild(a); //此处增加了将创建的添加到body当中 11 a.href = objectUrl; 12 a.download = this.formData.channelName; 13 a.target = ‘_blank‘; 14 a.click(); 15 a.remove(); //将a标签移除 16 })
原文:https://www.cnblogs.com/jay-sans/p/10688781.html