1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 后台返回的数组包对象格式的数据转换成表格数据格式的方法

后台返回的数组包对象格式的数据转换成表格数据格式的方法

时间:2021-08-30 05:23:54

相关推荐

后台返回的数组包对象格式的数据转换成表格数据格式的方法

后台返回的数组包对象格式的数据转换成表格数据格式的方法

transformDate(res) {const mapInfo = {id: '编号',password: '密码',mobile: '手机号',username: '姓名',timeOfEntry: '入职日期',formOfEmployment: '聘用形式',correctionTime: '转正日期',workNumber: '工号',departmentName: '部门',staffPhoto: '头像地址'}// // 取出所有的属性名字const pros=Object.keys(res[0])// 将属性名字转换成中文const header=props.map(zhwen=>mapInfo[zhKey])//取出所有数据const data = res.map(obj => Object.values(obj))return {header, data }}async hExportExcel() {// 1. ajax获取数据await this.loadEmployees()// console.log(this.list)// 2. 数据格式转换 ---> header, dataconst {header, data } = this.transformDate(this.list)console.log(header, data)// 3. 导出成excel文件// import('@/xxxx/Export2Excel').then(excel => {// excel.export_json_to_excel({// header,// data,// filename: '员工数据'//})//})},

在这里插入

描述

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。