使用vue-print-nb打印el-table问题总结

css样式添加媒体查询 @media print {} 样式只有在打印的时候才会生效

1、解决单选框复选框打印时选中消失的问题

javascript 复制代码
@media print {
  // 解决单选框复选框打印时选中消失的问题
  ::v-deep .el-radio__input,
  ::v-deep .el-checkbox__input {
    -webkit-print-color-adjust: exact;
    -moz-print-color-adjust: exact;
    color-adjust: exact;
  }
}

2、解决表格打印时表格显示不全的问题

javascript 复制代码
 // 解决表格打印时表格显示不全的问题
  ::v-deep table {
    table-layout: auto !important;
  }
  ::v-deep .el-table__header-wrapper .el-table__header {
    width: 99% !important;
  }
  ::v-deep .el-table__body-wrapper .el-table__body {
    width: 98% !important;
  }
  ::v-deep #print table {
    table-layout: fixed !important;
  }

  ::v-deep .el-table__fixed {
    display: none;
  }

3、解决table 序号打印错乱问题

javascript 复制代码
 ::v-deep .el-table .el-table__cell.is-hidden > * {
    visibility: visible;
    font-size: 12px;
  }

4、不需要打印的内容 在标签上添加class名 noPrint 即可

javascript 复制代码
  .noPrint {
    display: none;
  }
  @page {
    size: auto;
    // margin: 3mm; // 页边距
  }

其他打印样式

javascript 复制代码
  // form 表单打印样式调整
  ::v-deep .el-form-item__label {
    padding: 0;
    width: 90px !important;
  }
  ::v-deep .el-form-item__content {
    margin-left: 90px !important;
  }
  ::v-deep .el-select__caret {
    opacity: 0;
  }
  ::v-deep .el-form-item__label {
    padding: 0;
    width: 90px !important;
  }
  // 清除input边框
  ::v-deep .el-input__inner {
    max-width: 180px;
    padding: 0px;
    border: 0;
  }
  ::v-deep .el-table {
    .el-input__inner {
      display: none;
    }
  }
  // el-select 多选清除边距,icon和背景
  ::v-deep .el-input__icon {
    display: none;
  }
  ::v-deep .el-tag {
    padding: 0;
    border-width: 0;
  }
  ::v-deep .el-tag__close {
    display: none;
  }
相关推荐
毕设源码-朱学姐5 小时前
【开题答辩全过程】以 工厂能耗分析平台的设计与实现为例,包含答辩的问题和答案
java·vue.js
老前端的功夫6 小时前
Vue 3 性能深度解析:从架构革新到运行时的全面优化
javascript·vue.js·架构
天天扭码6 小时前
如何实现流式输出?一篇文章手把手教你!
前端·aigc·ai编程
前端 贾公子7 小时前
vue移动端适配方案 === postcss-px-to-viewport
前端·javascript·html
GISer_Jing8 小时前
AI营销增长:4大核心能力+前端落地指南
前端·javascript·人工智能
明远湖之鱼8 小时前
一种基于 Service Worker 的渐进式渲染方案的基本原理
前端
前端小端长9 小时前
Vue 中 keep-alive 组件的原理与实践详解
前端·vue.js·spring
FeelTouch Labs9 小时前
Nginx核心架构设计
运维·前端·nginx
雪球工程师团队9 小时前
别再“苦力”写后台,Spec Coding “跑” 起来
前端·ai编程