这种方法可以在打印的页面中添加样式,新页面跳转打印

 doPrint(ids){
            var titleHTML=document.getElementById(ids).innerHTML;
            var OpenWindow = window.open("");
            OpenWindow.document.write('<!DOCTYPE html><html lang="zh-cn">');
            OpenWindow.document.write("<head>");
            OpenWindow.document.write('<meta charset="utf-8">');
            OpenWindow.document.write('<title></title>');
            OpenWindow.document.write('<style>.table{width: 100%;font-size:13px;}</style>');
            OpenWindow.document.write('</head>');
            OpenWindow.document.write('<body><div class="layout-g-content" >);
            OpenWindow.document.write('</div></body>');
            OpenWindow.document.write('</html>');
            OpenWindow.document.getElementById("p").innerHTML= titleHTML;
            window.setTimeout(function(){
                OpenWindow.print();
                OpenWindow.close();
             }, 500);
          },

 

相关文章:

  • 2022-12-23
  • 2021-05-27
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-20
猜你喜欢
  • 2021-12-05
  • 2021-12-05
  • 2022-12-23
  • 2021-07-14
  • 2021-11-11
  • 2022-12-23
相关资源
相似解决方案