HTML/Html-Javascript/二维码/index-jc.html

101 lines
2.6 KiB
HTML
Raw Normal View History

2023-05-01 19:37:40 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- 引入资源 -->
<script src="./js/jquery.min.js"></script>
<script src="./js/qrcode.min.js"></script>
<style>
#app {
background-color: salmon;
width: 220px;
height: 220px;
box-sizing: border-box;
padding: 10px;
/* position: absolute;
bottom: 363px;
left: 184px; */
}
#qrcode {
width: 345px;
height: 345px;
}
.bodyCode {
width: 750px;
position: relative;
}
.bodyCode img {
width: 100%;
}
</style>
</head>
<body>
<!-- <div class="bodyCode">
<div id="app">
<div id="qrcode"></div>
</div>
<img src="./beijin.jpg" alt="">
</div> -->
<input id="text" type="text" value="wxp://f2f0dTmFHoy4ykvPLTAxFWC2Vu7bsLaQenhn8LEH590zZX0"
style="width:80%" /><br />
<!-- 画二维码的盒子 -->
<div id="app">
<div id="qrcode"></div>
<img id="logo"
src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa.zdmimg.com%2F201604%2F22%2F57197db54326d2842.png_a200.jpg&refer=http%3A%2F%2Fa.zdmimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644069953&t=b7f77fa0903dd6245db2dcd30bdffcaa"
style="display: none;">
</div>
<script type="text/javascript">
// 画二维码 的配置
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "wxp://f2f0dTmFHoy4ykvPLTAxFWC2Vu7bsLaQenhn8LEH590zZX0",
width: 200,
height: 200,
colorDark: "#FA8072", // 二维码的颜色
colorLight: "#ffffff", // 二维码的反色
correctLevel: QRCode.CorrectLevel.H,
typeNumber: -1,//计算模式
correctLevel: 2,//二维码纠错级别
});
// console.dir(QRCode);
// 获取input内容 并生成二维码
// 你要再画
// qrcode.clear(); // 清除代码
// qrcode.makeCode("http://www.w3cschool.cc"); // 生成另外一个二维码
// 实现更改 input内容 就实时跟新二维码
let text = document.querySelector("#text");
text.oninput = function () {
this.value
qrcode.clear(); // 清除代码
qrcode.makeCode(this.value); // 生成另外一个二维码
}
</script>
</body>
</html>