首先再项目中的main.js中的引入print.js
https://wws.lanzous.com/iVVhadhkusd
import Print from ‘@/utils/print‘ //根据自己文件的位置配置地址
Vue.use(Print)
单页面局部打印
<template> <div style="width:100%;" ref="printarea"> <img style="width:100%;" :src="imgPath"/> </div> <el-button @click="printimg()">打印</el-button> </template> <script> export default { data () { return { imgPath: ‘‘ } }, methods: { printimg () { this.$print(this.$refs.printarea) } } } </script>