导出excel的功能效果实现

<el-button @click="exportExcel" >
<i style="display: inline-block;">
<img src="@/assets/img/export.png" alt>
</i> 导出
</el-button>
==============》
methods: {
exportExcel () {
console.log(111)
if (this.tableData.length) {
this.exportLoading = true
const params = {
title: ['序号', '所属一级分区', '所属二级分区','时间(月)','供水量','环比上月'],
key: ['category1', 'category2', 'category3','category4','category5'],
data: this.tableData,
autoWidth: true,
filename: '供水量统计'
}
excel.export_array_to_excel(params)
this.exportLoading = false
} else {
this.$Message.info('表格数据不能为空!')
}
}
},
原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/11187509.html