From 158118a370584067f2a3c9444270360432bd5b8b Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Fri, 24 Jun 2022 23:22:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=8E=AF=E5=A2=83=E5=AF=BC=E5=87=BApdf?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=94=A4=E8=B5=B7=E6=89=93=E5=8D=B0=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=EF=BC=88#126=20#129=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/print.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/print.ts b/src/utils/print.ts index 3a58357d..5498e5a5 100644 --- a/src/utils/print.ts +++ b/src/utils/print.ts @@ -74,8 +74,13 @@ export const print = (printNode: HTMLElement, size: PageSize) => { const handleLoadIframe = () => { iframeContentWindow.focus() iframeContentWindow.print() + } + + const handleAfterprint = () => { + iframeContentWindow.removeEventListener('afterprint', handleAfterprint) document.body.removeChild(iframe) } iframe.addEventListener('load', handleLoadIframe) + iframeContentWindow.addEventListener('afterprint', handleAfterprint) } \ No newline at end of file