vue js实现打印

<div id = "panel">
    内容
</div>
printContent() {
      const wpt = document.getElementById("panel");
      const newContent = wpt.innerHTML;
      const oldContent = document.body.innerHTML;
      document.body.innerHTML = newContent;
      document.getElementsByTagName("body")[0].style.zoom = 0.86;  //控制打印时的缩放
      window.print(); //打印方法
      window.location.reload();
      document.body.innerHTML = oldContent;
    },
posted @ 2020-12-21 09:41  Smile浅笑  阅读(575)  评论(0编辑  收藏  举报