vue 打印指定的内容

//第一种

npm install vue-easy-print --save

要打印的页面引入  import vueEasyPrint from "vue-easy-print"

组件注册

components: {

vueEasyPrint,

},

使用

<vueEasyPrint ref="easyPrint" tableShow>

<img class="aa" src="./icon/miandan.jpg" alt="" /> //打印内容

</vueEasyPrint>

打印按钮//

<el-button @click="print">打印3</el-button>  

方法:

print(){

this.$refs.easyPrint.print()

}

//第二种

npm install vue-print-nb --save

// 1. 全局挂载 main.js
import Print from 'vue-print-nb'
Vue.use(Print)
 
// or
 
// 2. 自定义指令
import print from 'vue-print-nb'
directives: {
  print
}

使用

<!--//通过按钮来调用-->
<el-button type="primary" @click="dialogVisible" v-print="print">打印</el-button>
 
<!--//需要打印的页面-->
<div id="printMe" ref="print">
      
            <p>什么玩意儿</p>
        </div>
</div>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值