下载后端给的数据生成xls文件
// 导出数据
pullStoreList() {
let params = this.form
params.isJsonData = true
this.api.post(`url`, params, { responseType: 'blob' }).then(res => {
this.download(res)
})
},
download(data) {
if (!data) { return }
// let text = `${this.schoolName}` + new Date().toLocaleDateString()
let text = `${this.schoolName}`
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', `${text}.xls`)
document.body.appendChild(link)
link.click()
},
网友评论