位置: 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)(农场新区)

  • 当期所得税是否是当期缴纳的所得税
  • 发票冲红重开,重开时是按新税率还是旧税率
  • 出口合同包括哪些条款
  • 更正个税申报需要做账吗
  • 无票收入应该怎么做
  • 调用系统服务出错核心征管后端
  • 转给子公司发工资分录
  • 应收职工欠款属于负债吗
  • 月末结转各项费用支出479000
  • 职工食堂支出明细表
  • 进口汽车消费税的计算公式
  • 个人借款利息是多少才合法
  • 加工生产产品的地方 用两个字形容
  • 申报过的印花税怎么删除
  • 评估所得征税方法是一种控制纳税人逃税和避税的措施
  • 采购折扣怎么结转成本?
  • 公司章程上的出资时间2050年
  • 股票持有多久可以打新股
  • 银票贴现需要银行授信吗
  • 无产权的建筑出售怎么办
  • 冲销暂估购入原材料的账务处理?
  • 增值税减免附加税用计提吗
  • 发放的离职补偿金怎么做账
  • 小规纳税人租金可以记入成本吗
  • 任务栏图标重叠一起
  • 华为鸿蒙双击背面打开健康码
  • 差错更正未来适用法
  • nod32kui.exe - nod32kui是什么进程 作用是什么
  • 无形资产初始计量的表述
  • php io操作
  • PHP:pcntl_get_last_error()的用法_PCNTL函数
  • 公司报销客户的差旅费
  • 员工离职的类型
  • 股东分红企业代扣个税
  • 拔缴经费收入
  • 房贷计算器搜房网
  • 出售长期股权投资的交易费用
  • 会计记账凭证摘要如何编写
  • 外埠存款通过哪个会计账户核算?
  • 明星身价几十亿
  • 租入厂房需做环保检测吗
  • 固定资产原值怎么确定
  • 会计月末账务处理程序
  • mongodb添加环境变量
  • 跨年租金如何确权
  • 清包工可以有一部分小料吗
  • 小规模纳税人收普票和专票有什么区别
  • sql如何进行事务操作
  • 计提城建税的会计分录怎么写
  • 装潢装修费用属于营改增
  • 其他业务收入的现金流放哪里?
  • 公司没有收入怎么办
  • 公司个人薪金怎么交税
  • 或有租金租赁
  • vmware安装macos10.15
  • winsock2
  • wpl是什么文件
  • linux批量替换文件夹名称
  • centos7图形安装
  • Win7系统启动密码
  • vps如何搭建ss
  • linux设置服务器ip地址
  • Extjs中DisplayField的日期或者数字格式化扩展
  • ie11滚动条样式
  • div+css布局的步骤
  • opengl编程实例
  • button按钮类型
  • linux shell脚本攻略(第3版)
  • android view详解
  • vue中使用类class
  • mailto的使用技巧分享
  • shell脚本关闭指定程序
  • android电话簿
  • 广东省电子税务局app下载
  • 入户走访时宣传内容
  • 印花税没有做税种认定
  • 服务协议属于哪类合同
  • 税务上如何界定收入
  • 员工的生育津贴计入工资总额吗
  • 两不一欠自查报告怎么写
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设