<p class="dialogCare"> <span>hello word!</span> //要打印的内容</p> <button @click="printBtn()">打 印</button> printBtn(){ let newstr = document.getElementsByClassName('dialogCare')[0].innerHTML; console.log(newstr) window.document.body.innerHTML = newstr; let oldstr = window.document.body.innerHTML; window.print(); window.location.reload(); //解决打印之后按钮失效的问题 window.document.body.innerHTML = oldstr; return false; },
相关推荐: