1、下载依赖包
npm install -S file-saver xlsx
插件详细介绍
https://github.com/SheetJS/js-xlsx
https://github.com/eligrey/FileSaver.js
2、引用依赖包
import FileSaver from 'file-saver';
import XLSX from 'xlsx';
3、表格导出excel
html
<el-table id="out-table" :data="tableData">
<el-table-column prop="id" label="数据源编号">
<template scope="scope">
<span>{
{scope.row.id}}</span>
</template>
</el-table-column>
</el-table>
<el-button type="button" @click="exportFunc">质量问题报表</el-button>
js
exportFunc(e) {
// 从表生成工作簿对象
var wb = XLSX.utils.table_to_book(document.querySelector(&