1. xxx.sh文件下载

success_download(name){
var download_file_name = name.split('.')[0]
var xhr = new XMLHttpRequest()
var url = '/load_balance/download/'
// 设置响应类型为blob类型
// xhr.responseType = "blob"
xhr.onload = function(){
if(this.status == "200"){
var result = JSON.parse(xhr.response).data
// 将文件流保存到a标签
var blob = new Blob([result], {type: 'text/plain'})
var aElem = document.createElement('a')
document.body.appendChild(aElem)
aElem.href = window.URL.createObjectURL(blob)
aElem.download = "下载文件_" + download_file_name + ".sh"
aElem.onload = function(){
window.URL.revokeObjectURL(aElem.href)
}
aElem.click()
document.body.removeChild(aElem)
}else{
alert("导出失败")
}
}
}