重点:responseType: 'blob'
pageExport () {
this.$axios.post(this.gwu.cont.url.electricityExport, this.param, {responseType: 'blob'})
.then((res) => {
const blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'})
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
// filename自定义
let datestr = this.gwu.dateFormat.dtsyyyyMMdd(new Date())
let filename = this.$t('message.ELECTRICITYMETER').concat(datestr).concat('.xlsx')
downloadElement.style.display = 'none'
downloadElement.href = href
downloadElement.download = filename
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
console.info('export ok!!!!')
}).catch(() => {
console.info('export failed!!!!')
})
},