ファイルのダウンロード方法
MainItemAPI.downloadFileUsingPOST({ PROJECTID:this.projectid、 $ CONFIG:{ responseType: 'ブロブ' //关键、解决响应流问题 } }) .then(RES => { CONSTブロブ=新たなBLOB([res.data] {タイプ: 'application / vnd.openxmlformats-officedocument.spreadsheetml.sheet'}) const disposition = res.headers ["content-disposition"] const filenameRegex = / filename [^; = \ n] * =((['" ])。*?\ 2 | [^; \ n] *)/; const matches = filenameRegex.exec(disposition); const filename = matches [1] .replace(/ ['"] / g、' '); if(typeof window.navigator.msSaveBlob!== 'undefined'){ // IEと互換性があり、window.navigator.msSaveBlob:ファイルをローカルに保存します) } window.navigator.msSaveBlob(blob、decodeURI(filename)) } else { //新しいURLを作成し、FileオブジェクトまたはBlobオブジェクトのアドレスをポイントします const blobURL = window.URL.createObjectURL(blob) //のタグを作成しますダウンロードリンクにジャンプします consttempLink = document.createElement( 'a') tempLink.style.display = 'none' tempLink.href = blobURL tempLink.setAttribute( 'download'、decodeURI(filename)) //互換性:一部のブラウザーブラウザはHTML5ダウンロード属性をサポートしていません if(typeof tempLink.download === 'undefined'){ tempLink.setAttribute( 'target'、 '_ blank') ますdocument.body.appendChild(tempLink) //挂取a¸签 tempLink.click() document.body.removeChild(tempLink) //释放ブロブURL地址 window.URL.revokeObjectURL(blobURL) } this.exportloading = false })。catch((error)=> { this.exportloading = falsethis 。$ message.error(error.message); })