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