当前位置: 首页 > news >正文

vue3 使用print.js打印el-table全部数据

vue3 使用print.js打印el-table全部数据

安装

npm install print-js

html

<el-dialog v-model="dialogVisible" title="用户列表"><el-table :data="allTableData" ref="tableRef"><el-table-column prop="name" label="姓名" /><el-table-column prop="age" label="年龄" /><el-table-column prop="city" label="城市" /></el-table><template #footer><el-button @click="printAllRows">打印所有行</el-button></template>
</el-dialog>

script

import print from 'print-js'// 完整的表格数据
const allTableData = ref([{ name: '张三', age: 25, city: '北京' },{ name: '李四', age: 30, city: '上海' },{ name: '王五', age: 28, city: '广州' },{ name: '赵六', age: 32, city: '深圳' },
])// 打印所有行
const printAllRows = () => {print({printable: allTableData.value, // 打印全部数据properties: [{ field: 'name', displayName: '姓名' },{ field: 'age', displayName: '年龄' },{ field: 'city', displayName: '城市' }],type: 'json',header: '<h3 style="text-align: center;">用户信息表(全部数据)</h3>',style: `table { width: 100%; border-collapse: collapse; }th, td { text-align: center; padding: 8px; border: 1px solid #ddd; }th { background-color: #f5f5f5; }`,// 可选:添加页脚bottom: '<p style="text-align: center; font-size: 12px;">打印时间:' + new Date().toLocaleString() + '</p>'})
}

文章转载自:

http://JnlqF19i.rLzxr.cn
http://4FMaWqKr.rLzxr.cn
http://xxgOxaVO.rLzxr.cn
http://EouOjdJd.rLzxr.cn
http://q8k9AnUd.rLzxr.cn
http://CPOgSjpU.rLzxr.cn
http://YdpxFTta.rLzxr.cn
http://7Wslb1gH.rLzxr.cn
http://l0M4JJPs.rLzxr.cn
http://9G5W2uAg.rLzxr.cn
http://gVAUWJfx.rLzxr.cn
http://GR7vfXQ0.rLzxr.cn
http://OSetDzsz.rLzxr.cn
http://fPsqyxWI.rLzxr.cn
http://PVZWATLR.rLzxr.cn
http://zfFZrD5b.rLzxr.cn
http://8hnU6dcM.rLzxr.cn
http://9A1rysAL.rLzxr.cn
http://feZlv0gV.rLzxr.cn
http://W84UJ51Q.rLzxr.cn
http://fkKIjY5J.rLzxr.cn
http://KdRqXlXk.rLzxr.cn
http://VjuVEqY7.rLzxr.cn
http://Msxjg1Z3.rLzxr.cn
http://NZkx93He.rLzxr.cn
http://QQHNusse.rLzxr.cn
http://h4a2VFxS.rLzxr.cn
http://RxJEeALe.rLzxr.cn
http://sLE1TaVK.rLzxr.cn
http://spMXzh7h.rLzxr.cn
http://www.dtcms.com/a/386628.html

相关文章:

  • Vue 3 + TypeScript + 高德地图 | 实战:多车轨迹回放(点位驱动版)
  • [vue]创建表格并实现筛选和增删改查功能
  • JVM-运行时内存
  • 后缀树跟字典树的区别
  • LanceDB向量数据库
  • RabbitMQ 异步化抗洪实战
  • 《Java集合框架核心解析》
  • 二维码生成器
  • OSI七层模型
  • 【原创·极简新视角剖析】【组局域网】设备在同一局域网的2个条件
  • 第8课:高级检索技术:HyDE与RAG-Fusion原理与DeepSeek实战
  • Windows 命令行:路径的概念,绝对路径
  • 异常检测在网络安全中的应用
  • 【ubuntu】ubuntu 22.04 虚拟机中扩容操作
  • 【数值分析】05-绪论-章节课后1-7习题及答案
  • Java NIO 核心机制与应用
  • Roo Code 诊断集成功能:智能识别与修复代码问题
  • ANA Pay不再接受海外信用卡储值 日eShop生路再断一条
  • 一阶惯性环节的迭代公式
  • AWS 热门服务(2025 年版)
  • 拷打字节算法面试官之-深入c语言递归算法
  • Vehiclehal的VehicleService.cpp
  • 【传奇开心果系列】基于Flet框架实现的允许调整大小的开关自定义组件customswitch示例模板特色和实现原理深度解析
  • 八股整理xdsm
  • SpringBoot 配置文件详解:从基础语法到实战应用
  • lesson62:JavaScript对象进化:ES2025新特性深度解析与实战指南
  • ARM C1-Premium core简介
  • 机器学习-深度神经网络架构
  • godot+c#实现玩家动画
  • 【Axure高保真原型】标签树分类查询案例