后端返回視頻地址,前端獲取并且下載
$.ajax({
url : 'url',
data : {
攜帶參數(shù):參數(shù)
},
dataType: "json",
success:function(data) {
//下載視頻
fetch(data.MediaUrl).then(res => res.blob()).then(blob => {
const a = document.createElement('a');//創(chuàng)建a標(biāo)簽
document.body.appendChild(a)
a.style.display = 'none'
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download =data.Name;
a.click();
document.body.removeChild(a)
window.URL.revokeObjectURL(url);下載
});
}
});
點(diǎn)擊下載
瀏覽器就下載該視頻
本文摘自 :https://www.cnblogs.com/