npm install file-saver --save
npm install xlsx --save
npm install script-loader --save-dev
到 https://pan.baidu.com/s/1DiIGxik9HaanMQwx2ICGAg 下载插件(密码:fkkg)
'vendor': path.resolve(__dirname, '../src/vendor')
export_Excel() {
var listStudent = null;
this.axios.get('api/exportStudentList').then((response) => {
listStudent = response.data.list;
})
//↑ 是获取数据
this.$confirm('确定要导出表格数据么?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
require.ensure(\[\], () => {
const {
export\_json\_to\_excel
} = require('../vendor/Export2Excel')
const tHeader = \['ID', '姓名', '年龄', '性别', '生日'\]
const filterVal = \['id', 'name', 'age', 'sex', 'birthday'\]
const list = listStudent
const data = this.formatJson(filterVal, list)
export\_json\_to\_excel(tHeader, data, '商品管理列表')
})
}).catch(() => {})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v\[j\]))
}
导出之后长这样
手机扫一扫
移动阅读更方便
你可能感兴趣的文章