标签:evo cli mamicode nload canvas 打印 info code 简单
对于普通吃瓜群众而言,只需要下载单个文件就够了,于是我总结了一个简单可行的方法!
http://www.doc88.com/p-3651708817002.html
function downloadPages(from, to) { for (i = from; i <= to; i++) { const pageCanvas = document.getElementById(‘page_‘ + i); if (pageCanvas === null) { break; } const pageNo = parseInt(String(i)); setTimeout(() => { console.log("==pageNo==>>", pageNo); ((num) => { console.log("开始打印第" + num + "页"); pageCanvas.toBlob( blob => { const anchor = document.createElement(‘a‘); anchor.download = ‘page_‘ + num + ‘.png‘; anchor.href = URL.createObjectURL(blob); anchor.click(); URL.revokeObjectURL(anchor.href); } ); })(pageNo); }, 500 * pageNo); } }
downloadPages(1, 18);
ok,直接下载到本地了
标签:evo cli mamicode nload canvas 打印 info code 简单
原文地址:https://www.cnblogs.com/wangjae/p/14113734.html