1这里使用jquery的 jquery.qrcode.js 来生成二维码相关的代码如下:
1 首先引入
<script src="/static/js/jquery-2.1.1.min.js"></script> <script src="/static/js/jquery.qrcode.js"></script>
2 相关的js入下 <script > // jQuery(function(){ // //jQuery('#qrcode').qrcode("http://www.baidu.com"); // jQuery('#qrcode').qrcode({width: 200,height: 200,text:"http://www.baidu.com"}); // }) function two(){ var test = $("#name").val(); //jQuery('#qrcode').qrcode("http://www.baidu.com"); jQuery('#qrcode').qrcode(test); } </script>
3 html的页面入下,比较简单
<body> <input type="text" id="name" placeholder="输入内容"> <button type="button" οnclick="two()" class="btn btn-primary">确定</button> <br> <p id="qrcode" ></p> </body>
功能实现:当在页面输入 http://www.163.com 然后点击确定入下图
手机微信扫描 上面二维码可以进入手机 163 网页