vue使用vue-print 多页打印带表头

vue使用vue-print 多页打印带表头

多分页带表头的公共模板
https://www.cnblogs.com/Vena/p/17774181.html

<template>
  <div>
    <div id="printArticle" class="container">
      <TABLE>
     	<!-- 公共拥有的头部 start -->
        <THEAD>
	        <TR>
		        <TH>
		        </TH>
	        </TR>
        </THEAD>
       	<!-- 公共拥有的头部 end -->
		<!-- 表单内容 start -->
        <TBODY>
        	<TR>
            	<TD>
            		<!-- 根据自己的需要插入容,可以直接插入div,也可以插入table -->
					<table>
						<thead>
							<tr>
								<th>序号</th>
								<th>编码</th>
								<th>名称</th>
								<th>规格</th>
								<th>分类</th>
							</tr>
						</thead>
						<tbod>
							<tr v-for="item in row.details" :key="item.fid">
								<td>{{ item.fid }}</td>
								<td>{{ item.code }}</td>
								<td>{{ item.name }}</td>
								<td>{{ item.model }}</td>
								<td>{{ item.type }}</td>
							</tr>
						</tbody>
					</table>
            	</TD>
        	</TR>
        </TBODY>
        <!-- 表单内容 end-->
		<!-- 公共拥有的尾部 start-->
        <TFOOT>
	        <TR>
	        	<TD></TD>
	        </TR>
        </TFOOT>
        <!-- 公共拥有的尾部 end -->
      </TABLE>
    </div>
    
	<div class="flex-align-center-justify-center">
	      <el-button class="button-wh" type="primary" v-print="'#printArticle'">打印</el-button>
    </div>
  </div>
</template>

CSS样式(按照自己页面修改样式)

<style lang="scss" scoped>
.container {
  zoom: 0.8;
  box-sizing: border-box;
  padding: 0;
  background-color: #fff;
  border: 1px solid #000;

  @page {
    size: auto;
    margin: 0;
  }

  @media print {
    * {
      color: #000 !important;
    }

    table {
      border-collapse: collapse;
      table-layout: fixed;
      width: 100%;
      border-spacing: 0;
    }

    table, tbody, thead {
      width: 100% !important;
    }

    table,table tr td {
      border:none;
    }

    .template-print {
      width: 100% !important;
      font-size: 14px;
    }

  }


  .row1{
    border-bottom: 1px solid #000;
    text-align: center;
    width: 100%;
    display: flex;
    align-items: stretch;
    line-height: 25px;

    .row1-col{
      border-right: 1px solid #000;
      display: inline-block;
      float: left;
    }
  }

  .row-span{
    margin-right: 10px;
  }
}
</style>
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值