导出 引入 HTML methods中
Vue-cli实现打印页面内容功能
export function print(content, w = null, h = null) { const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; w = +w === 0 ? width : w; h = +h === 0 ? height : h; const left = ((width / 2) - (w / 2)) + dualScreenLeft; const top = ((height / 2) - (h / 2)) + dualScreenTop; var myWindow = window.open("", "打印", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + top + ", left=" + left); //需要打印的页面样式(自定义) var style = "<style type='text/css'>.print{width:100%;height:100%}...等等</style>"; myWindow.document.write(content + style); myWindow.focus(); myWindow.document.close(); //关闭输出流, 显示选定的数据 myWindow.print(); //打印当前窗口 return myWindow; }
import { print } from "@/print函数的位置";
<div class="dayin" id="print">我是需要打印的内容</dev> <div> <button @click.passive="doPrint">打印</button> </div>
doPrint () { var windows = print(document.getElementById('print').innerHTML); windows.close(); },
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算