vue中的vue-print-nb如何實(shí)現(xiàn)頁(yè)面打印
更新時(shí)間:2022年04月21日 10:45:06 作者:今天代碼敲了嗎
這篇文章主要介紹了vue中的vue-print-nb如何實(shí)現(xiàn)頁(yè)面打印,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
安裝
npm install vue-print-nb --save
在main.js中全局引入
import Print from 'vue-print-nb' Vue.use(Print);
頁(yè)面中使用
備注:只會(huì)打印id=printMe內(nèi)的網(wǎng)頁(yè)
<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>

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue父子組件傳值不能實(shí)時(shí)更新的解決方法
Vue是一個(gè)以數(shù)據(jù)驅(qū)動(dòng)、組件化的前端框架,其中組件化是Vue中較為重要的概念之一,組件之間的通信則成為Vue中較為普遍的需求,下面這篇文章主要給大家介紹了關(guān)于vue父子組件傳值不能實(shí)時(shí)更新的解決方法,需要的朋友可以參考下2023-05-05
vue 地圖可視化 maptalks 篇實(shí)例代碼詳解
這篇文章主要介紹了vue 地圖可視化 maptalks 篇,本文分步驟通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2019-05-05
el-form的label和表單自適應(yīng)填滿一行且靠左對(duì)齊方式
這篇文章主要介紹了el-form的label和表單自適應(yīng)填滿一行且靠左對(duì)齊方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
vue3.0+vite2實(shí)現(xiàn)動(dòng)態(tài)異步組件懶加載
學(xué)了vue寫項(xiàng)目這么久,忽然發(fā)現(xiàn)路由懶加載的寫法,節(jié)省了加載所有路由的時(shí)間。本文主要介紹了vue3.0+vite2實(shí)現(xiàn)動(dòng)態(tài)異步組件懶加載,感興趣的可以了解一下2021-06-06
實(shí)例分析vue循環(huán)列表動(dòng)態(tài)數(shù)據(jù)的處理方法
本篇文章給大家詳細(xì)分享了關(guān)于vue循環(huán)列表動(dòng)態(tài)數(shù)據(jù)的處理方法以及相關(guān)知識(shí)點(diǎn)內(nèi)容,有需要的朋友們參考下。2018-09-09
基于vue3.0.1beta搭建仿京東的電商H5項(xiàng)目
這篇文章主要介紹了基于vue3.0.1beta搭建仿京東的電商H5項(xiàng)目,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05

