在Angular 2中坚持打印弹出窗口

时间:2017-01-31 12:45:00

标签: angular

`print(): void {
    let printContents, popupWin;
    printContents = document.getElementById('print-section').innerHTML;
    console.log(printContents);
    popupWin = window.open('', '_blank', 'top=0,left=0,height=100%,width=auto');
    popupWin.document.open();
    popupWin.document.write(`
      <html>
        <head>
         <link rel="stylesheet" href="../../style/style.css">
        </head>

        <body onload="window.print();window.close()">
        <h2>Transaction Details</h2>
          ${printContents}
        </body>
      </html>`
    );
    popupWin.document.close();
}`

当我运行此代码时,即使添加了延迟,打印弹出窗口也不会加载CSS样式表。谁能告诉我哪里弄错了?或者我该怎么做才能使它发挥作用?

0 个答案:

没有答案