- npm安装
npm install js-file-download
2.引用
import fileDownload from 'js-file-download';
3.使用
//download.js
import request from '@/utils/request-authority'
export function download(query) {
return request({
url: 'xxx.do',
method: 'get',
params: query,
'responseType': 'blob'
})
}
// download.vue
let filName = 'xxx文件'
download().then(response => {
fileDownload(response, fileName + '.xlsx')
});