vue实现局部预览打印

html

<div id="subOutputRank-print">
             <h1>11111</h1>
         </div>

js

doPrint(e){
               let subOutputRankPrint = document.getElementById('subOutputRank-print');
                console.log(subOutputRankPrint.innerHTML);
                let newContent =subOutputRankPrint.innerHTML;
                let oldContent = document.body.innerHTML;
                document.body.innerHTML = newContent;
                window.print();
                window.location.reload();
                document.body.innerHTML = oldContent;
                return false;
            }

 

posted @ 2018-11-08 10:13  麦麦芽  阅读(4859)  评论(0编辑  收藏  举报