1引入
安装
标准:
npm install vue-json-excel
国内:
yarn add vue-json-excel
main.js 入口文件
import JsonExcel from "vue-json-excel"; // 导出
Vue.component("downloadExcel", JsonExcel);
2使用 导出
1- template 中使用
<a-button
type="primary"
:disabled="disabled"
style="margin-bottom: 10px"
@click="exportData"
>
<download-excel
:data="exportmemberList"
:fields="exportColumns"
name="订单列表报表.xls"
>
导出</download-excel
>
</a-button>
2- js中
//导出表头
exportColumns: {
订单编号: {
field: "no",
callback: (value) => {
return " " + value;
},
},
回收员: "recycler_name",
所属区域: "area_name",
完成时间: "finished_at",
订单状态: "exportstatus",
订单金额: "actual_price",
回收员利润: "recycler_profit",
},
exportmemberList: [],