一. 安装
npm i qrcodejs2
二. 页面
<template>
<div class="about">
<!-- 二维码容器 -->
<div
class="erweima"
ref="qrCodeWrapper"
id="qrcode"
style="width: 210px; margin: 15px auto"
></div>
</div>
</template>
<script>
import QRCode from "qrcodejs2"; // 引入
export default {
created() {
this.$nextTick(() => {
new QRCode(this.$refs.qrCodeWrapper, {
text: "https://www.baidu.com/",
width: 200,
height: 200,
// colorDark: this.colorFront, // 前景色
// colorLight: this.colorBack, // 背景色
// correctLevel: QRCode.CorrectLevel.L, // 容错率级别 L M Q H
});
});
},
};
</script>