- html
<el-button @click="downlFile" type="primary">下载模板</el-button>
2
downlFile(){
接口().then(data => {
var dataList = [];
dataList.push(data.data);
let header = data.headers['content-disposition'];
let fileName = '下载文件名称' + '.xls'
if (window.navigator.msSaveOrOpenBlob) {
try {
let blobObject = new Blob(dataList, { type: "application/zip" })
window.navigator.msSaveOrOpenBlob(blobObject, fileName)
} catch (e) {
console.log('系统错误', e);
}
} else {
let url = window.URL.createObjectURL(
new Blob(binaryData, { type: "application/zip" })
);
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
}
})
}