vue 打印html


1、https://github.com/xyl66/vuePlugs_printjs從這個路徑下載print.js。放到你的代碼中

2、我是放到我本地一個js文件中。

3、引入當前文件

//打印插件
import Print from './utils/print'
Vue.use(Print) // 注冊

4、頁面應用

<template>
    <section ref="print" style="max-height: 1000px;width: 800px;margin: 0 auto;">
        <p>我的打印的內容</p>
    </section>
</template>

<script>
    this.$print(this.$refs.print)
</script>

把需要打印的東西放入這個標簽中就可以了。

當內容中有不需要打印的東西時可以這樣

<p class="no-print">不要打印</p>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM