1.安装js-file-download
npm install js-file-download
2.引入对应的功能模块
import fileDownLoad from 'js-file-download' import Axios from 'axios'//ajax请求 import store from '@/store'//设置token
3.代码段
exportData(){ var _this = this Axios({ url:'ajax url' method: 'post', headers: { 'Authorization': token }, data:{ licenseNo:_this.searchForm.licenseNo, }, responseType: 'blob', }).then(res => { fileDownload(res.data, new Date().getTime()+ '.xlsx'); }) }