后端返回blob文件流,前端下载文件的整个过程

时间:2025-03-28 10:36:12
  • <template>
  • <el-button @click="doDownload(row)" type="text" size="small" v-double-click>
  • <svg-icon icon-class="download-1" class="upload-color" />
  • </el-button>
  • </template>
  • <script>
  • import { download } from '@/utils/download';
  • import { downRpt } from '@/api/report';
  • export default {
  • name: '',
  • components: { },
  • data() {
  • return {};
  • },
  • mounted() {},
  • methods: {
  • // 下载
  • doDownload(row) {
  • // (row);
  • if (!row.rstPath) {
  • messageTip({ message: '还未生成报告', type: 'error' });
  • return;
  • }
  • downRpt({ rstPath: row.rstPath })
  • .then(res => {
  • download(res, res.fileName);
  • })
  • .catch(() => {});
  • },
  • }
  • };
  • </script>