【JavasSript】后台返回 csv base64 下载

const exort = async () => {
  try {
    const { data } = await zhjxDownloadFile({
      meta: {
        user_token: localStorage.getItem('user_token'),
        file_name: activeName.value,
        image_indexs: activePage.value,
      },
    });
    let uri = 'data:text/csv;base64,' + data.csv;
    const a = document.createElement('a');
    a.download = `${activeName.value.replace('.pdf', '')}-page${activePage.value}.csv`;
    a.href = uri;
    a.click();
    ElMessage.success('导出成功');
  } catch (error) {}
};
posted @ 2023-05-08 11:43  努力挣钱的小鑫  阅读(26)  评论(0编辑  收藏  举报