<template>
<div class="box">
<div>
<span ref="qrCodeUrl"></span>
</div>
</div>
</template>
<script>
import QRCode from "qrcodejs2";
export default {
data() {
return {
};
},
components: {
},
mounted() {
this.creatQrCode();
},
methods: {
creatQrCode() {
let a = new QRCode(this.$refs.qrCodeUrl, {
text: "https://www.baidu.com/", // 需要转换为二维码的内容
width: 200,
height: 200,
colorDark: "black", //#000000为黑色
colorLight: "white",
});
console.log("二维码:", a);
},
},
};
</script>
<style scoped>
.box {
width: 200px;
height: 200px;
margin: 0 auto;
}
/* 组件样式 */
</style>
vue 生成二维码
最新推荐文章于 2024-09-02 08:08:55 发布