Vue 导出blob兼容IE


    axios.get(url, {
        params: param,
        responseType: 'arraybuffer'
      }).then((response) => {
          loading.close();
          const csvData = new Blob([response.data], {type: 'application/x-xlsx'})//response.data要导出的内容
          const file_name = 'xxx导出' + '.xlsx';
          // for IE
          if (window.navigator && window.navigator.msSaveOrOpenBlob) {
              window.navigator.msSaveOrOpenBlob(csvData, file_name);
          }
          // for Non-IE (chrome, firefox etc.)
          else {
              var a = document.createElement('a');
              var url = window.URL.createObjectURL(csvData);
              a.href =  url;
              a.download = file_name;
              a.click();
              a.remove();
              window.URL.revokeObjectURL(url);
          }
      }).catch((error) => { })


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM