2.0vue导出excel
如果没有插件导入
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
导入依赖
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
table>>>>>>id
id="out-table"
方法里面如下
//da导出表格
exportExcel () { /* generate workbook object from table */
var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
/* get binary string as output */
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
try { FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }),
'订单详情.xlsx')
} catch (e) {
if (typeof console !== 'undefined')
console.log(e, wbout)
} return wbout
},
// 导入表格
一点点学习,一丝丝进步。不懈怠,才不会被时代淘汰