后端返回的数据以表格的形式导出
1.安装vue-json-excel 插件
npm install vue-json-excel -S
2.main.js里面引入并注册使用
import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)
3、页面中使用
<download-excel class="export-excel-wrapper" :data="json_data" :fields="json_fields" name="filename.xls">
<el-button type="success" size="small" @click="downLoadInfo()">下载平台信息</el-button>
</download-excel>
json_data:需要导出的数据
json_fields:自主选择要导出的字段,若不指定,默认导出全部数据中心全部字段
属性名 类型 描述
data Array 需要导出的数据,支持中文
fields Object 定义需要导出数据的字段
name String 导出excel的文件名
type String 导出excel的文件类型(xls,csv),默认是xls
data() {
return: {
json_fields: {
"用户名:":