js二维码的生成方法

一、js生成二维码有很多方法这里只写个人制作的一种

二、效果图

三、直接上代码

<!DOCTYPE html>
<html>
<head>
<title>Javascript 二维码生成库:QRCode</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<script type="text/javascript" src="https://cdn.staticfile.net/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/qrcodejs/1.0.0/qrcode.min.js"></script>
</head>
<body>
<input id="text" type="text" value="https://www.runoob.com" style="width:80%" /><br />
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
	width : 100,
	height : 100
});

function makeCode () {		
	var elText = document.getElementById("text");
	
	if (!elText.value) {
		alert("Input a text");
		elText.focus();
		return;
	}
	
	qrcode.makeCode(elText.value);
}

makeCode();

$("#text").
	on("blur", function () {
		makeCode();
	}).
	on("keydown", function (e) {
		if (e.keyCode == 13) {
			makeCode();
		}
	});
</script>
</body>
</html>

希望可以对大家有所帮助;

相关推荐

  1. Element UI +Vue页面生成方法

    2024-03-20 13:40:05       40 阅读
  2. uniapp小程序使用uQRCode.js生成

    2024-03-20 13:40:05       34 阅读
  3. 生成

    2024-03-20 13:40:05       63 阅读
  4. 自己生成

    2024-03-20 13:40:05       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-20 13:40:05       91 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-20 13:40:05       97 阅读
  3. 在Django里面运行非项目文件

    2024-03-20 13:40:05       78 阅读
  4. Python语言-面向对象

    2024-03-20 13:40:05       88 阅读

热门阅读

  1. Linux的shell脚本

    2024-03-20 13:40:05       31 阅读
  2. GPT-4会让我们更接近真正的AI革命吗?

    2024-03-20 13:40:05       42 阅读
  3. npm audit fix --force

    2024-03-20 13:40:05       39 阅读
  4. 设计模式(行为型设计模式——命令模式)

    2024-03-20 13:40:05       40 阅读
  5. 面试题:linux的常用命令!!!

    2024-03-20 13:40:05       35 阅读
  6. 如何开通点卡核销接口

    2024-03-20 13:40:05       57 阅读
  7. 数据库选型-Mysql和Mongodb对比

    2024-03-20 13:40:05       44 阅读
  8. InitializingBean学习

    2024-03-20 13:40:05       44 阅读
  9. 机器学习 - PyTorch使用流程

    2024-03-20 13:40:05       43 阅读
  10. TCP总结

    TCP总结

    2024-03-20 13:40:05      40 阅读