下载视频到本地
$(document).on("click",".download",function(){
var url=$(this).attr("url");
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer'; // 返回类型blob
xhr.onload = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
let blob = this.response;
// 转换一个blob链接
let u = window.URL.createObjectURL(new Blob([blob],{ type: 'video/mp4' }))
let a = document.createElement('a');
a.download ="video";
a.href = u;
a.style.display = 'none'
document.body.appendChild(a)
a.click();
a.remove();
}
};
xhr.send()
})