var url = 'http://xxxx.com/xxxx.zip;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function () {
if (this.status === 200) {
var blob = new Blob([this.response]);
var blobUrl = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = blobUrl;
//设置下载文件的名字
a.download = '新文件名'
a.click();
window.URL.revokeObjectURL(blobUrl);
}
};
xhr.send();