第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

vue axios 請(qǐng)求二進(jìn)制流excel文件,response亂碼

vue axios 請(qǐng)求二進(jìn)制流excel文件,response亂碼

慕妹3242003 2019-03-14 18:15:51
問(wèn)題:當(dāng)axios發(fā)起post請(qǐng)求,后端返回的是二進(jìn)制流excel文件,前臺(tái)獲取response時(shí)出現(xiàn)亂碼問(wèn)題,求解決方法response返回亂碼數(shù)據(jù)。 downloadModel(){        // window.location.href = window.open(axios.defaults.baseURL +'/settlement/payableCheck/download/template');        // let downLoadModel = window.open();        // let fileDownload = require('js-file-download');        this.$post('/settlement/payableCheck/download/template',{params:null},{responseType: 'arraybuffer'}).then(res => {        // this.$get('/settlement/payableCheck/download/template').then(res => {          console.log(res);          // let fileName = res.headers['content-disposition'].match(/fushun(\S*)xls/)[0];          // fileDownload(res,fileName);          let blob = new Blob([res], {type: "application/vnd.ms-excel;charset=utf-8"});          // let objectUrl = URL.createObjectURL(blob);          // window.location.href = objectUrl;          var link = document.createElement('a');          link.href = window.URL.createObjectURL(blob);          link.download = "對(duì)賬模板";          link.click();        }).catch((e) => {          this.$message.warning('下載失敗');          console.log(e);        })      },強(qiáng)行text打開(kāi)還是亂碼
查看完整描述

5 回答

?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

response亂碼不是很正常嗎?你強(qiáng)行用text打開(kāi)一下你的excel看看是不是亂碼?你看下載文件就行了,不用管response的文本輸出。


查看完整回答
反對(duì) 回復(fù) 2019-04-14
?
www說(shuō)

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超8個(gè)贊

這個(gè)亂碼應(yīng)該是后端設(shè)置的編碼問(wèn)題


查看完整回答
反對(duì) 回復(fù) 2019-04-14
?
米琪卡哇伊

TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊

responseType: 'blob' blob 設(shè)置這個(gè)類型呢? {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"} ,還有 別用編輯打開(kāi)excel啊

查看完整回答
反對(duì) 回復(fù) 2019-04-14
  • 5 回答
  • 0 關(guān)注
  • 2900 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)