//下载账单
downloadBill(type){
//获取账单内容
billApi.downloadBill(this.billDate, type).then(response => {
console.log(response)
const element = document.createElement('a')
element.setAttribute('href', 'data:application/vnd.ms-excel;charset=utf-8,'
+ encodeURIComponent(response.data.result))
element.setAttribute('download', this.billDate + '-' + type)
element.style.display = 'none'
element.click()
})
}
后端返回一个下载Excel表格的url,要PC浏览器打开下载,前端代码设计
最新推荐文章于 2023-11-24 17:27:50 发布