import printJS from 'print-js'; import html2canvas from 'html2canvas'; export const mapPrint = { defaultDomId: "printDiv", print(domId) { const that = this; if (!domId) { domId = that.defaultDomId; } that.beforePrint(); html2canvas(document.getElementById(domId)).then(canvas => { const imageData = canvas.toDataURL("image/jpeg", 1); that._print(imageData); }); }, beforePrint() { // TODO }, _print(imageData) { const that = this; printJS({ printable: imageData, type: 'image', documentTitle: ' ' }); that.afterPrint(); }, afterPrint() { // TODO }, };
html2canvas截图打印
最新推荐文章于 2024-07-22 15:30:16 发布