1.安装js-file-download
javascript
npm install js-file-download --save
2.在页面引入使用
javascript
import fileDownload from "js-file-download"
3.调用导出接口
javascript
/** 导出 */
handleExportGoodsExchange() {
API_Statistics.getstockExport(this.params).then(response => {
FileDownload(response, "XXXXX.xlsx");
});
}
4.文件格式出现问题(在api)
javascript
/**
* 导出XXXX列表
* @param params
*/
export function getstockExport(params) {
return request({
url: 'admin/stock/statistics/export',
method: 'get',
responseType: 'blob',
loaidng: false,
params
})
}