1.安装依赖
npm install vue-json-excel
yarn add vue-json-excel
2.页面引入
import JsonExcel from "vue-json-excel";
export default {
components: {
"download-excel": JsonExcel,
},
}
3.组件引用
<download-excel :fields="field" :data="List" name="客户统计表" type="xls">
<el-button size="mini" type="warning">导出数据</el-button>
</download-excel>
4.写入导出数据
data(){
return{
field:{
导出中文名:'数据对应字段名'
},
List:[],//需要导出的数据
}
}