- List item
因功能需要用文件流做下载或导出功能,以下代码仅供参考
xls格式配置:
type: ‘application/vnd.ms-excel;charset=utf-8’,
xlsx格式配置:type:‘application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet;charset=utf-8’
<el-button type="primary" plain @click="allDownload">下载</el-button>
methods:{
allDownload() {
const params = this.exportAllParams
console.log(params)
// const params = JSON.parse(JSON.stringify(this.searchParams))
delete params.current
delete params.size
delete params.total
allExportList(params).then((res) => {
const blob = new Blob([res], {
type: 'application/vnd.ms-excel'
})
const a = document.createElement('a')
const href = window.URL.createObjectURL(blob)
a.href = href
a.download = '实时监控'
document.body.appendChild(a)
a.click()
// console.log(a)
document.body.removeChild(a)
window.URL.revokeObjectURL(href)
})
},
}
文章来源地址https://www.toymoban.com/news/detail-725047.html
文章来源:https://www.toymoban.com/news/detail-725047.html
到了这里,关于Vue下载文件流的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!