使用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;
  }
相关推荐
梦曦i几秒前
RouterLink v2.5.0:H5端原生能力全面回归
前端·uni-app
小林ixn14 分钟前
React + Zustand + JWT:从零实现登录鉴权与请求拦截
前端·react.js·前端框架
葡萄城技术团队18 分钟前
下拉多选类型单元格:在 SpreadJS 里接入 xm\-select
前端
粥里有勺糖43 分钟前
视野修炼-技术周刊第130期 | 光影效果
前端·javascript·github
小岛前端1 小时前
AI Skills 已经封神,但新的问题却越来越严重!
前端·后端·github
拖孩1 小时前
一个人 + AI 做的小程序,上线 15 天赚了 10 块 5
前端·后端·微信小程序
用户93983829415991 小时前
安卓自动化脚本热更新怎么做?不重新打包 APK 也能更新代码
前端
全栈项目管理程序猿1 小时前
ArcGIS JS 基础教程(13):屏幕坐标与地理坐标互转
javascript
猫七先生1 小时前
在 React 里用 PMTiles 自托管底图
前端
tanghonghanhaoli1 小时前
【图书翻译】有意义的游戏设计:桌面游戏的方法论与心理学(第1、2章)
前端·游戏·ui