post请求下载excal数据表,兼容ie10
作者:
吖_7c06 | 来源:发表于
2019-10-18 18:30 被阅读0次let times = {data:'this.data'}
this.$axios
.post(url, this.qs.stringify(times),{responseType: 'blob'}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
.then(response => {
// console.log(response)
const content = response.data
const blob = new Blob([content])
const fileName = 'CRM结果导出.csv'
if ('download' in document.createElement('a')) { // 非IE下载
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 { // IE10+下载
navigator.msSaveBlob(blob, fileName)
}
})
本文标题:post请求下载excal数据表,兼容ie10
本文链接:https://www.haomeiwen.com/subject/ibdwmctx.html
网友评论