作用:打印指定dom
使用:
-
安装 yarn add vue-print-nb (npm i vue-print-nb) 插件
-
导入
-
在main.js导入 import Print from 'vue-print-nb'
-
-
注册
-
Vue.use(Print)
-
-
使用
-
在指定dom加上id id=‘xxx‘
-
-
在按钮上输入该指令 v-print="{id:'xxx'}"
需求:只打印页面中这部分信息
<el-form label-width="220px">
<div id="printMessage">
<!-- 工号 入职时间 -->
.....省略
</div>
<!-- 保存个人信息 -->
<el-row class="inline-info" type="flex" justify="center">
<el-col :span="12">
<!-- 设置点击打印的按钮 -->
<el-button
v-print="{ id: 'printMessage' }"
type="primary"
>打印员工个人信息</el-button>
</el-col>
</el-row>
</el-form>
....
点击该按钮之后 效果: