3.1
this.$http.post("download", { fileName: file.filename } ,{responseType: 'arraybuffer'}) // 或者responseType: 'blob'
.then(function(response) {前端
let blob = new Blob([response.data], {type: 'application/vnd.ms-excel'}); if (window.navigator.msSaveOrOpenBlob) { //兼容ie window.navigator.msSaveBlob(blob, file.filename); } else { let downloadElement = document.createElement('a'); let href = window.URL.createObjectURL(blob); //建立下載的連接 downloadElement.href = href; downloadElement.download = file.filename;//下載後文件名 document.body.appendChild(downloadElement); //此寫法兼容火狐 let evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, false); downloadElement.dispatchEvent(evt); document.body.removeChild(downloadElement); } })
4.分享連接 https://www.oschina.net/question/3910533_2283267ios