1. <a d ownload class="down" title="">  
  2. function download(src,name) {
    // 创建隐藏的可下载链接
    var eleLink = document.createElement('a');
    eleLink.href = src;
    eleLink.download = name;
    eleLink.style.display = 'none';
    eleLink.href = src;
    document.body.appendChild(eleLink);
    eleLink.click();
    document.body.removeChild(eleLink);
    }

  3. //js下载文件
  4. case 'show':
    var urls = data.fileurl;

    var three = urls.split(".");
    var last = '.' + three[three.length - 1];
    last = last.toLowerCase();
    if (last == ".pdf") {
    common.CreateAddForm('查看', urls, {
    width: '100%',
    height: '100%'
    });
    } else {
    download(urls, data.filename);
    }
    break;

 

 

/*
          const aLink = document.createElement('a')
          //const newfileName = response.headers['content-disposition'].split('=')[1]
          let blob = new Blob([resJson],{ type: 'application/vnd.ms-excel' })
          aLink.href = URL.createObjectURL(blob)
          aLink.setAttribute('download', `名称`)
          aLink.click()
          window.URL.revokeObjectURL(blob)
 */

 

 

 

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-11-10
  • 2021-10-18
  • 2022-12-23
  • 2021-12-19
  • 2021-12-21
猜你喜欢
  • 2021-11-12
  • 2021-09-12
  • 2022-12-23
  • 2021-10-16
  • 2021-09-12
  • 2021-11-28
  • 2021-06-11
相关资源
相似解决方案