async export_data() { let zip = new JSZip() // 下载文件并添加到 ZIP for (const i of this.tableData) { const data = await fetch(i.path).then(response => response.arrayBuffer()) const imageByteStream = new Uint8Array(data).subarray(1024) // 获取图片信息 const blob = new Blob([imageByteStream], { type: 'image/jpeg' }) zip.file(`${i.name}.jpg`,blob) } let content = await zip.generateAsync({ type: 'blob' }) saveAs(content,`近30天_图片数据.zip`) }
ps: i.path是 文件路径
jszip.js cdn地址:https://cdn.bootcdn.net/ajax/libs/jszip/3.10.1/jszip.min.js
FileSaver.js cdn地址:https://cdn.bootcdn.net/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js