2024最新qrcode.min.js生成二维码Demo

找了一堆代码一堆GPT,终于给写对了:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>QRCode Example</title>
  <script src="https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js"></script>
</head>
<body>

<canvas id="canvas"></canvas> <!-- Canvas 元素 -->

<script>
  // 获取 canvas 元素
  const canvas = document.getElementById('canvas');

  // 使用 qrcode 库生成二维码
  QRCode.toCanvas(canvas, 'Hello World', function (error) {
    if (error) {
      console.error(error);
    } else {
      console.log('QR code successfully generated!');
    }
  });
</script>

</body>
</html>
相关推荐
泡海椒5 小时前
Java PDF 报表开发:一页简历的两种版式风格对比与折行避坑
java·开发语言·pdf
2601_962885725 小时前
如何用 Python 计算终极振荡器(Ultimate Oscillator, UOS)?
开发语言·python
benchmark_cc7 小时前
一次获取多只股票实时行情:QuantDash `quotes.get(symbols=[...])` 批量快照
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
geovindu7 小时前
python: PCA
开发语言·后端·python·算法
__万波__8 小时前
嵌入式存储技术--1.Flash物理存储
java·开发语言
Chen_harmony8 小时前
十六、ALV树
开发语言·c++
qq_274475158 小时前
第 28 篇:Promise 全解析:状态、then/catch/finally、静态方法 all/race/allSettled/any
开发语言·javascript
西西弗Sisyphus9 小时前
C++ 最小 Agentic Loop 实现 - 回调函数系列 - 初识回调(5)
开发语言·c++
程序员小杰@9 小时前
Java 统一报文转换 + 签名验签完整介绍
java·开发语言
Java后端的Ai之路10 小时前
Anthropic 官方文章《Building always-on agents》构建指南
开发语言·网络·python