位置: IT常识 - 正文

vue-print 实现打印功能(vue实现打印)

编辑:rootadmin
vue-print 实现打印功能 目录一、安装1. Vue22. Vue3二、基本使用1. 直接打印页面HTML2. 个性化设置3. 打印URL三、API一、安装1. Vue2npm install vue-print-nb --saveimport Print from 'vue-print-nb'// Global instruction Vue.use(Print);//or// Local instructionimport print from 'vue-print-nb'directives: { print }2. Vue3npm install vue3-print-nb --save// Global instruction import { createApp } from 'vue'import App from './App.vue'import print from 'vue3-print-nb'const app = createApp(App)app.use(print)app.mount('#app')//or// Local instructionimport print from 'vue3-print-nb'directives: { print }二、基本使用1. 直接打印页面HTML

推荐整理分享vue-print 实现打印功能(vue实现打印),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:vue实现打印功能的两种方法,vue-print-nb-jeecg,vue-easy-print,vue实现打印功能的两种方法,vue-print-nb遇到的坑,vue-print-nb-jeecg,vue-print-nb,vue-print-nb-jeecg,内容如对您有帮助,希望把文章链接给更多的朋友!

1)方法 ① 给要打印的部分设置一个 id ② 在打印按钮中添加 v-print="'#id名'"

vue-print 实现打印功能(vue实现打印)

2)代码(以表格为例)

<template> <div> <a-button v-print="'#printMe'">打印</a-button> <a-table :columns="columns" :data-source="data" bordered id="printMe"> </a-table> </div></template><script>const columns = [ { title: 'Name', dataIndex: 'name', }, { title: 'Cash Assets', className: 'column-money', dataIndex: 'money', }, { title: 'Address', dataIndex: 'address', },];const data = [ { key: '1', name: 'John Brown', money: '¥300,000.00', address: 'New York No. 1 Lake Park', }, { key: '2', name: 'Jim Green', money: '¥1,256,000.00', address: 'London No. 1 Lake Park', }, { key: '3', name: 'Joe Black', money: '¥120,000.00', address: 'Sidney No. 1 Lake Park', },];export default { data() { return { data, columns, }; },};</script>2. 个性化设置

1)方法 打印按钮的 v-print 绑定一个对象 2)代码

<template> <div class="box"> <a-table :columns="columns" :data-source="data" bordered id="printMe"></a-table> <a-button v-print="printContent" class="btn no-print">打印</a-button> </div></template><script>const columns = [ { title: 'Name', dataIndex: 'name', }, { title: 'Cash Assets', className: 'column-money', dataIndex: 'money', }, { title: 'Address', dataIndex: 'address', },];const data = [ { key: '1', name: 'John Brown', money: '¥300,000.00', address: 'New York No. 1 Lake Park', }, { key: '2', name: 'Jim Green', money: '¥1,256,000.00', address: 'London No. 1 Lake Park', }, { key: '3', name: 'Joe Black', money: '¥120,000.00', address: 'Sidney No. 1 Lake Park', },];export default { data() { return { data, columns, tableHead: '测试表格', printContent: { id: "printMe", // 打印的区域 preview: false, // 预览工具是否启用 previewTitle: '这是预览标题', // 预览页面的标题 popTitle: '', // 打印页面的页眉 extraCss: "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css", extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>', previewBeforeOpenCallback() { console.log('正在加载预览窗口') }, previewOpenCallback() { console.log('已经加载完预览窗口') }, beforeOpenCallback(vue) { vue.printLoading = true console.log('打开之前') }, openCallback(vue) { vue.printLoading = false console.log('执行了打印') }, closeCallback() { console.log('关闭了打印工具') }, clickMounted(vue){ console.log('点击了打印按钮'); vue.printContent.popTitle = vue.tableHead // 动态设置页眉 } } } }};</script>

3)效果展示 ① 预览工具

3. 打印URL

1)方法 ① 给 打印按钮的 v-print 绑定一个对象 ② 对象添加 url 属性

2)代码

<template> <div class="box"> <a-table :columns="columns" :data-source="data" bordered></a-table> <a-button v-print="printContent" class="btn no-print" >打印</a-button> </div></template><script>const columns = [ { title: 'Name', dataIndex: 'name', }, { title: 'Cash Assets', className: 'column-money', dataIndex: 'money', }, { title: 'Address', dataIndex: 'address', },];const data = [ { key: '1', name: 'John Brown', money: '¥300,000.00', address: 'New York No. 1 Lake Park', }, { key: '2', name: 'Jim Green', money: '¥1,256,000.00', address: 'London No. 1 Lake Park', }, { key: '3', name: 'Joe Black', money: '¥120,000.00', address: 'Sidney No. 1 Lake Park', },];export default { data() { return { data, columns, tableHead: '测试表格', printContent: { url: 'http://localhost:8081/', // 打印的url preview: false, // 预览工具是否启用 previewTitle: '这是预览标题', popTitle: '', // 打印页面的页眉 extraCss: "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css", extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>', } } },};</script>三、APIParameExplainTypeOptionalValueDefaultValueidRange print ID, required valueString––standardDocument type (Print local range only)Stringhtml5/loose/stricthtml5extraHeadAdd DOM nodes in the node, and separate multiple nodes with , (Print local range only)String––extraCss New CSS style sheet , and separate multiple nodes with ,(Print local range only)String––popTitle Content of label (Print local range only)String––openCallbackCall the successful callback function of the printing toolFunctionReturns the instance of Vue called at that time–closeCallbackClose the callback function of printing tool successFunctionReturns the instance of Vue called at that time–beforeOpenCallbackCallback function before calling printing toolFunctionReturns the instance of Vue called at that time–urlPrint the specified URL. (It is not allowed to set the ID at the same time)String––asyncUrlReturn URL through ‘resolve()’ and VueFunction––previewPreview toolBoolean–falsepreviewTitlePreview tool TitleString–‘打印预览’previewPrintBtnLabelThe name of the preview tool buttonString–‘打印’zIndexCSS of preview tool: z-indexString,Number–20002previewBeforeOpenCallbackCallback function before starting preview toolFunctionReturns the instance of Vue–previewOpenCallbackCallback function after fully opening preview toolFunctionReturns the instance of Vue–clickMountedClick the callback function of the print buttonFunctionReturns the instance of Vue–
本文链接地址:https://www.jiuchutong.com/zhishi/284133.html 转载请保留说明!

上一篇:Win7系统该文件没有程序与之关联来执行该操作的(win7系统文件在哪里可以找到)

下一篇:新农场公园内盛开的蓝花楹树,布里斯班 (© Walter Bibikow/Danita Delimont)(农场新区)

  • 华为下载的app桌面没有显示(华为下载的app桌面没有显示怎么办)

    华为下载的app桌面没有显示(华为下载的app桌面没有显示怎么办)

  • 小度摄像头关闭怎么打开(小度摄像头关闭了是不是亮红灯)

    小度摄像头关闭怎么打开(小度摄像头关闭了是不是亮红灯)

  • 微信扫码扫不出来是怎么回事(微信扫码扫不出来怎么回事)

    微信扫码扫不出来是怎么回事(微信扫码扫不出来怎么回事)

  • 手机熄屏后时间显示怎么设置(手机灭屏时显示时间)

    手机熄屏后时间显示怎么设置(手机灭屏时显示时间)

  • 华为p20怎么看电池寿命(华为P20怎么看电池实际容量)

    华为p20怎么看电池寿命(华为P20怎么看电池实际容量)

  • oppor11怎样关闭后后运行程序(oppor11怎样关闭拍照声音)

    oppor11怎样关闭后后运行程序(oppor11怎样关闭拍照声音)

  • ios不能微信支付了吗(ios不可以微信支付)

    ios不能微信支付了吗(ios不可以微信支付)

  • 拼多多账号注销了还可以再注册吗(拼多多账号注销后订单还在吗)

    拼多多账号注销了还可以再注册吗(拼多多账号注销后订单还在吗)

  • 苹果7闪退发烫是什么原因(苹果7闪退发热)

    苹果7闪退发烫是什么原因(苹果7闪退发热)

  • 操作系统的分类(操作系统的分类及具体举例)

    操作系统的分类(操作系统的分类及具体举例)

  • 微信转账显示当前交易异常,请降低金额重试(微信转账显示当前交易存在风险,暂时不能付款)

    微信转账显示当前交易异常,请降低金额重试(微信转账显示当前交易存在风险,暂时不能付款)

  • a13相当于电脑什么CPU(a13相当于电脑什么显卡)

    a13相当于电脑什么CPU(a13相当于电脑什么显卡)

  • oracle初始密码(oracle初始化账号密码)

    oracle初始密码(oracle初始化账号密码)

  • word竖式除号怎么打(word怎么打除法竖式的符号)

    word竖式除号怎么打(word怎么打除法竖式的符号)

  • 手机照片怎么连在一起(手机照片怎么连接打印机打印)

    手机照片怎么连在一起(手机照片怎么连接打印机打印)

  • 陌陌关注多久可以语音(陌陌关注多久可以打电话)

    陌陌关注多久可以语音(陌陌关注多久可以打电话)

  • 苹果无线耳机支持安卓吗(苹果无线耳机支持ios12吗)

    苹果无线耳机支持安卓吗(苹果无线耳机支持ios12吗)

  • 安卓tim下载的文件在哪里(安卓tim下载的文件打不开)

    安卓tim下载的文件在哪里(安卓tim下载的文件打不开)

  • 拼多多揽收超时怎么办(拼多多揽收超时1小时)

    拼多多揽收超时怎么办(拼多多揽收超时1小时)

  • 开通收钱码有什么坏处(开通收钱码有什么好处)

    开通收钱码有什么坏处(开通收钱码有什么好处)

  • vivox27安全模式怎么关闭(vivox27安全模式会怎么样)

    vivox27安全模式怎么关闭(vivox27安全模式会怎么样)

  • 如何删除收到的坦白说(如何删除收到的礼物)

    如何删除收到的坦白说(如何删除收到的礼物)

  • e3400 是哪一年的(e3400相当于现在什么处理器)

    e3400 是哪一年的(e3400相当于现在什么处理器)

  • 小米8开发者选项在哪里(小米8开发者选项最小宽度默认是多少)

    小米8开发者选项在哪里(小米8开发者选项最小宽度默认是多少)

  • ccsvchst.exe是什么进程 ccsvchst.exe应用程序错误怎么办(ccs是什么软件)

    ccsvchst.exe是什么进程 ccsvchst.exe应用程序错误怎么办(ccs是什么软件)

  • 车辆购置税会计科目怎么做账
  • 一般纳税人购进货物用于免征增值税项目
  • 营业账簿印花税申报期限
  • 哪些情况需要提高警惕小心毒品
  • 老板故意拖欠税款怎么办
  • 简易征收预缴税款可以抵扣吗
  • 工会经费余额在借方怎么办
  • 建筑公司增值税税率9%
  • 预售收入是否可以退税
  • 转让土地使用权属于销售无形资产吗
  • 旅游业差额开票的票据可以累计一季度吗
  • 药店的成本费用有哪些
  • 物业公司营改增税务筹划方案
  • 增值税税率改革的意义
  • 一般纳税人专业分包税率
  • 小规模开普票要交税吗分录怎么做
  • 个人承担的社保计入管理费用吗
  • 小型微利企业年度汇算清缴报哪些报表
  • 个人给公司付款怎么做分录
  • 企业高管需要什么证书
  • 所有者权益类科目借贷方向
  • 办理税务迁移
  • 手把手教你win7换主板不重装系统的方法
  • 全民游戏盒子怎么卸载
  • 对公账户被诈骗转款728000会怎么样呢
  • 付款给代账公司的费用是什么科目
  • linux统计文件行数字数
  • 开发商没交税
  • 抵债资产怎么入账
  • 企业采购过程中发生的材料短缺
  • 计提消费税的会计科目
  • 中医诊所的税收分类编码
  • 图片防止侵权怎么写
  • 前端如何将项目分类
  • 权限管理实现的功能包括
  • 基于反事实因果推断的度小满额度模型
  • 织梦怎么建站
  • 前年度多交附加税怎么交
  • 织梦如何使用
  • 个税算错怎么办理退税
  • 计提以前年度的企业所得税
  • 成品油红字发票开具后库存数量如何冲回?
  • 套期保值是什么意思举个例子
  • 作废的增值税普通发票怎么处理
  • 增值税发票丢失怎么补开
  • 出差自己开车去开会怎么报销交通费
  • mysql操作步骤
  • 个体工商户核定征收超额怎么缴税
  • 会计税法的差异
  • 无形资产的后续支出,金额较大的应增加无形资产的价值
  • 风险纳税人认定条件2020
  • 企业政策性搬迁所得税管理办法解读
  • 房产税土地使用税会计分录
  • 营改增后租金收入交什么税
  • 其他收益和其他综合收益区别
  • 增值税进项发票抵扣期限是多少天?
  • 什么是存货周转天数
  • 认缴款和投资款区别
  • 商业折扣入账
  • sqlserver2000数据库安装教程
  • 错误的英文
  • win8系统和win7哪个好
  • windowsxp注册表在哪
  • mac触控板设置在哪
  • linux如何关闭selinux
  • Win10 Mobile RS2预览版14905更新内容大全:全新精致铃声
  • 电脑自带win8是装win7还是win10
  • ssh登录报错
  • windows7如何启动任务管理器
  • android滑动选择
  • 安卓接入点
  • node session
  • nodejsapi
  • include eigen
  • jquery左右移动动画效果
  • 解决的英文
  • 解决js请求服务问题
  • python append、extend与insert的区别
  • 使用SQLite数据库保存和处理数据
  • 职工周转房需要缴纳房产税吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设