1.效果图

2.安装
- 插件安装
npm i vue-plugin-hiprint
- 引入样式
复制一份hiprint/css/print-lock.css文件到public中,在index.html中引入
<link rel="stylesheet" type="text/css" media="print" href="<%= BASE_URL %>print-lock.css" />
3.引入插件
- 全局引入
import {
hiPrintPlugin } from 'vue-plugin-hiprint'
app.use(hiPrintPlugin)
- 局部引入
import {
hiPrintPlugin } from 'vue-plugin-hiprint'
4.完整代码
<template>
<div class="pageIndex">
<div class="topBtnBox">
<div class="paper">
<button v-for="(value, type) in paperSize" :key="type" @click="setPaper(type, value)">
{
{ type }}
</button>
<button @click="paperPopVisible = !paperPopVisible">自定义纸张</button>
<div class="popover">
<div class="popover-content" v-show="paperPopVisible">
<div>
<input class="input" v-model="paperWidth" type="number" placeholder="宽(mm)" />
<span>x</span>
<input class="input" v-model="paperHeight" type="number" placeholder="高(mm)" />
</div>
<button @click.stop="setPaperOther">确定</button>
</div>
</div>
<button @click="changeScale('+')">+</button>
<button @click="changeScale('-')">-</button>
<input v-model="scaleValue" disabled style="width: 40px; text-align: center" />
<button @click="changeScale(