<template>
<div id="app">
<div id="code" @click="handlePrint"></div>
</div>
</template>
<script>
import QRCode from "qrcodejs2";
export default {
name: "App",
methods: {
getCode() {
let text = `test 内容 1`; //内容
let params = {
text,
width: 400,
height: 400,
};
let code = new QRCode("code", params);
code.clear(); //清除二维码
code.makeCode(text); //生成另一个新的二维码
},
handlePrint() {
window.print();
},
},
mounted() {
this.getCode();
},
};
</script>
<style>
* {
padding: 0;
margin: 0;
}
#code {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
</style>
vue生成二维码并打印
最新推荐文章于 2024-08-20 11:29:48 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)