<script setup lang="ts">
import { ElButton } from 'element-plus';
import axiox from 'axios';

const downloadFile = () => {
  let url = '/api/downloadFile/'
  axiox({
    url,
    method: 'GET',
    responseType: 'blob'
  }).then(res => {
    // 下载文件
    console.log(res)
    const blob = new Blob([res.data], { type: 'application/x-sqlite3' });
    const link = document.createElement('a');
    link.href = window.URL.createObjectURL(blob);
    link.download = 'xdc.sqlite';
    link.click();
  })
  console.log('downloadFile');
}

</script>


<template>
  <ElButton type="primary" @click="downloadFile">导出文件</ElButton>
</template>