a链接下载oss链接文件

 const handleDownLoad = async (record) => {
    const ossFileUrl = ''; // 替换为实际的 OSS 文件链接
    const link = document.createElement('a');
    link.href = ossFileUrl;
    link.download = 'example.pdf';
    try {
      const response = await axios({
        url: ossFileUrl,
        method: 'GET',
        responseType: 'blob',
        onDownloadProgress: (progressEvent) => {
          const progress = Math.round((progressEvent.loaded / progressEvent.total) * 100);
          console.log(`下载进度:${progress}%`);
        },
      });
      document.body.appendChild(link);
      link.click();
      message.success('文件下载完成');
      console.log(response.data, '文件下载完成');
    } catch (error) {
      console.error('文件下载失败', error);
    }
  }

你可能感兴趣的:(javascript,前端,vue.js)