下载文件,使用a.download

var a = document.createElement('a')
a.download = row.fileName || 'pic'
a.href = row.src;
a.click()

预览文件

window.open(row.src)

 预览文件只能预览图片文件和pdf

a.download在跨域中是不能成功执行的,需要下载到本地

let url = 'http://jdvodtybjsmrk.vod.126.net/jdvodtybjsmrk/0-52153475237841-1591597756405-0-mix.mp4"         
var x = new XMLHttpRequest();
x.open("GET", url, true);
x.responseType = 'blob';
 x.onload=function(e) {
        var url = window.URL.createObjectURL(x.response)
        var a = document.createElement('a');
        a.href = url
        a.download = 'xiazai'; //下载后的文件名
       a.click()
 }
 x.send();
                    
                       

  

相关文章:

  • 2022-12-23
  • 2021-07-20
  • 2021-12-04
  • 2022-12-23
  • 2021-09-30
猜你喜欢
  • 2022-12-23
  • 2022-01-28
  • 2021-06-07
  • 2021-12-11
  • 2021-10-17
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案