安装 npm install vue-json-excel
在main.js里面全局注册
// 表格导出
import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)
修改vue-json-execl源码
将内容修改为<td style=`mso-number-format:\'\@\';`>
key值为execl表格title
使用
<download-excel
class="export-excel-wrapper"
:data="DetailsForm"
:fields="json_fields"
:header="title"
:name="title"
>
<!-- 上面可以自定义自己的样式,还可以引用其他组件button -->
<el-button type="success" size="small">导出</el-button>
</download-excel>
title: '计重数据统计',
// 表格内容
json_fields: {
'机构': 'agencyPointName',
'地磅': 'scaleName',
'菜品': 'dishName'
},
DetailsForm: [],