方法一:用jquery的二维码生成js库
html里代码:
<!DOCTYPE html>
<html>
<head>
<!--引入jquery,jquery.qrcode-->
<script type='text/javascript'src='http://cdn.staticfile/jquery/2.1.1/jquery.min.js'></script>
<script type="text/javascript"src="http://cdn.staticfile/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
</head>
<body>
<div id = "qrid"></div>
</body>
<script>
$(function(){
var qrstr = "https://www.xxx/xxx/xxx";
$('#qrid').qrcode(qrstr);//不指定二维码大写
$('#qrid').qrcode({width: 280,height: 280,text: qrstr});//指定二维码大小
});
</script>
</html>
方法二:用原生js的代码生成器,也需要js库
git下载路径:https://github/davidshimjs/qrcodejs
runoob更详细教程:http://www.runoob/w3cnote/javascript-qrcodejs-library.html
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'src='http://cdn.staticfile/jquery/2.1.1/jquery.min.js'></script>
<script type="text/javascript"src="js/qrcode.min.js"></script>
</head>
<body>
<div id = "qrid"></div>
</body>
<script>
$(function(){
var qrstr = "https://www.xxx/xxx/xxx";
new QRCode(document.getElementById("qrid"), qrstr);
});
</script>
</html>
更多推荐
js代码里链接生成二维码
发布评论