在Angular应用程序中打印时,我需要制作CSS样式,因此我决定放置<link rel="stylesheet" type="text/scss" href="../style.scss">
。我已经将css样式放入“ styles.scss”中,但是当我单击“打印”按钮时,这些样式仍然没有出现。我将如何解决此问题?请检查此链接
onPrint() {
let printContents, popupWin;
printContents = document.getElementById('printSection').innerHTML;
popupWin = window.open('', '_blank', 'top=0,left=0,height=100%,width=auto');
popupWin.document.open();
popupWin.document.write(`
<html>
<head>
<link rel="stylesheet" type="text/css" href="../styles.css">
</head>
<body onload="window.print();window.close()">${printContents}</body>
</html>`
);
popupWin.document.close();
}