文档:

https://github.com/davidshimjs/qrcodejs

<script src="./qrcode.js"></script>

<div id="qrcode"></div>

<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "https://www.pengshiyu.com/",
width: 128,
height: 128,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H,
});
</script>