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; }