fix: 尝试修复部分环境导出pdf无法唤起打印窗口(#126 #129)

This commit is contained in:
pipipi-pikachu 2022-06-24 23:22:48 +08:00
parent e6773a4d81
commit 158118a370

View File

@ -74,8 +74,13 @@ export const print = (printNode: HTMLElement, size: PageSize) => {
const handleLoadIframe = () => { const handleLoadIframe = () => {
iframeContentWindow.focus() iframeContentWindow.focus()
iframeContentWindow.print() iframeContentWindow.print()
}
const handleAfterprint = () => {
iframeContentWindow.removeEventListener('afterprint', handleAfterprint)
document.body.removeChild(iframe) document.body.removeChild(iframe)
} }
iframe.addEventListener('load', handleLoadIframe) iframe.addEventListener('load', handleLoadIframe)
iframeContentWindow.addEventListener('afterprint', handleAfterprint)
} }