let This = this
let ItemData = indexJSON.data.catalog.list
for (var i = 0; i < ItemData.length; i++) {
for (var j = 0; j < ItemData[i].children.length; j++) {
let tempItem = ItemData[i].children[j ]
This.FileDownloadBtn(tempItem.url, tempItem.name)
}
}
// 下载文件
FileDownloadBtn(PDFDownUrl, fileName) {
console.log(PDFDownUrl, fileName)
let This = this
const req = new XMLHttpRequest();
req.open('get', PDFDownUrl, true);
req.responseType = 'blob';
req.setRequestHeader('Content-Type', 'application/json');
req.onload = function() {
const data = req.response;
const blob = new Blob([data]);
const blobUrl = window.URL.createObjectURL(blob);
This.download(blobUrl, fileName);
};
req.send();
},
download(blobUrl, fileName) {
const a = document.createElement('a');
a.download = fileName;
a.href = blobUrl;
a.click();
},