<el-button
type="danger"
@click="expot"
icon="el-icon-download"
v-permission="'merchants:enter:tenant:export'"
>导出</el-button
>
// 导出excel表
expor(where) {
console.log(where, '导出elcel表');
this.req
.get('后端接口', {
params: where,//可以进行搜索条件帅选出来下载
deep: true,
responseType: 'blob'
})
.then((res) => {
this.$common.downFile(res);//这个this.$common是一个js文件,之后全局挂载
});
},
在src下面utils下面新建一个common.js
export default {
downFile(octetStream) {
let blob = new Blob([octetStream.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
});