printPic(event,item){//点击按钮回调函数//方式1://保存原先网页内容// let bdhtml=window.document.body.innerHTML; // window.document.body.innerHTML=`<img style="width:80%;height:80%;" src="http://localhost:8080/api/msg/pic/${item.bureauId}/${item.code}.jpg">`;// //把需要打印的指定内容赋给body.innerHTML// window.print(); //调用浏览器的打印功能打印指定区域// window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;//window.location.reload();//刷新当前窗口,否则页面其他事件失效//方式2:const printHTML = `<img style="width:90%;height:100%;" src="http://localhost:8080/api/msg/pic/${item.bureauId}/${item.code}.jpg">`;// 将打印的区域赋值给新窗口body,进行打印const newWindow = window.open('','');newWindow.document.write(printHTML);newWindow.window.print();//调用新窗口的打印newWindow.window.close();},:
100字范文,内容丰富有趣,生活中的好帮手!