這個是前端代碼
這個是后端代碼
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + name + ".zip");
System.Web.HttpContext.Current.Response.BinaryWrite(buffer);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();大神們 怎么解決啊
uj5u.com熱心網友回復:
這是我監視前端的回傳 出來的資料
uj5u.com熱心網友回復:
來個人,結貼了,送分uj5u.com熱心網友回復:
沒人嗎 ?送分了uj5u.com熱心網友回復:
我還是沒有解決,請教你下載沒有攜帶引數嗎uj5u.com熱心網友回復:
為啥洗掉我帖子,請教一下怎么了uj5u.com熱心網友回復:
解決了嗎 同問同問uj5u.com熱心網友回復:
兄弟 今天遇到了相同的問題,請問您解決了嗎?uj5u.com熱心網友回復:
已經解決了,代碼如下
axios.post(url, ResumeViewModel, { responseType: 'blob' }).then(function (res) {
if (res && res.status == 200) {
const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
var sFM = 'YYYY-MM-DD hh:mm:ss';
var df = moment().format(sFM) + '';
var fileName = '簡歷Word資料' + df + '.zip';
var fileNameStr = res.headers['content-disposition'] + "";
var index = fileNameStr.indexOf('=');
if (index > 0) {
fileName = fileNameStr.substr(index + 1);
fileName = decodeURIComponent(fileName)
}
if (that.judgeIE()) {
navigator.msSaveBlob(blob, fileName)
} else {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 釋放URL 物件
document.body.removeChild(elink);
}
} else {
this.$message({
message: "下載失敗,請重試!",
type: "warning"
});
}
that.$nextTick(function () {
loadingInstance.close();
});
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/138812.html
標籤:Ajax
下一篇:用JS給網頁input賦值失效
