欢迎来到代码驿站!

vue

当前位置:首页 > 网页前端 > vue

vue中的vue-print-nb如何实现页面打印

时间:2022-06-15 10:21:44|栏目:vue|点击:

安装

npm install vue-print-nb --save

在main.js中全局引入

import Print from 'vue-print-nb'
Vue.use(Print);

页面中使用

备注:只会打印id=printMe内的网页

<template>
  <div class="table">
    <div class="tableList">
      <div id="printMe">
        <div class="title">打印模板</div>
        <div class="content-table-three">
          <div class="table-name-three">XXXX</div>
          <div class="table-info-three">{{ list.fromName }}</div>
          <div class="table-name-three">XXXX</div>
          <div class="table-info-three">{{ list.fromIdCard }}</div>
          <div class="table-name-three">XXXX</div>
          <div class="table-info-three">{{ list.fromPhone }}</div>
        </div>
        <div class="content-table-three">
          <div class="table-name-three">XXXX</div>
          <div class="table-info-three">{{ list.fromName }}</div>
          <div class="table-name-three"XXXX</div>
          <div class="table-info-three">{{ list.fromIdCard }}</div>
          <div class="table-name-three">XXXX</div>
          <div class="table-info-three">{{ list.fromPhone }}</div>
        </div>
        <div class="content-table-two">
          <div class="table-name-two">XXXX</div>
          <div class="table-info-two">{{ list.reason }}</div>
          <div class="table-name-two">XXXX</div>
          <div class="table-info-two">{{ list.reason }}</div>
        </div>
        <div class="content-table-one">
          <div class="table-name-one">XXXX</div>
          <div class="table-info-one">{{ list.reason }}</div>
        </div>
        <div class="content-table-one">
          <div class="table-name-one">XXXX</div>
          <div class="table-info-one">{{ list.reason }}</div>
        </div>
        <div class="content-table-img">
          <div class="table-name-one">XXXX</div>
          <div class="table-info-img">
            <div class="imgsrc">
              <img
                v-if="list.img"
                :src="list.img"
              />
            </div>
          </div>
        </div>
        <div class="content-table-img">
          <div class="table-name-one">XXXX</div>
          <div class="table-info-img">
            <div class="imgsrc">
              <img
                v-if="list.img"
                :src="list.img"
              />
            </div>
          </div>
        </div>
      </div>
      <div  class="table-btn">
        <Button type="info" v-print="printObj" class="btn-no">打印</Button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "printInfo",
  data() {
    return {
      list:[],
      printObj: {
        id: "printMe",
        popTitle: "打印模板",
        extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
      },
    };
  },
  methods: {},
  computed: {},
  created() { },
};
</script>
<style   scoped>
.table {
  width: 100%;
  height: 100vh;
  overflow-y: scroll;
}
.tableList {
  width: 900px;
  margin: auto;
  margin-top: 20px;
}
.title {
  font-size: 20px;
  width: 100%;
  text-align: center;
}
.table-name-three,
.table-info-three {
  border: 0.55px solid;
  width: 16.7%;
}
.table-name-two,
.table-info-two {
  border: 0.55px solid;
  width: 25%;
  line-height: 100px;
  text-align: center;
}
.table-info-img {
  border: 0.55px solid;
  width: 75%;
}
.table-info-one {
  border: 0.55px solid;
  width: 75%;
}
.table-name-one {
  border: 0.55px solid;
  width: 25%;
}
.content-table-one,
.content-table-two,
.content-table-three {
  display: flex;
  height: 100px;
  width: 100%;
  line-height: 100px;
  text-align: center;
}
.content-table-img {
  display: flex;
  height: 100px;
  width: 100%;
  line-height: 100px;
  text-align: center;
}
img {
  max-width: 100%;
  height: 100%;
  background-size: 100%;
  background-repeat: no-repeat;
}
.imgsrc {
  width: 90%;
  margin: auto;
  height: 90%;
  margin-top: 5px;
}
.table-btn {
  margin-top: 20px;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  align-content: center;
}
</style>

上一篇:vue element 表头添加斜线的实现代码

栏    目:vue

下一篇:Vue使用$set和$delete操作对象属性

本文标题:vue中的vue-print-nb如何实现页面打印

本文地址:http://www.codeinn.net/misctech/204877.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有