注意引用
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
HTML代码
<!DOCTYPE html> <html> <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> <style> .qrCode{ position: relative; } #qrCodeIco{ position: absolute; width: 50px; height: 50px; left:35px; top:35px; } </style> </head> <body> <div> <img id="qrCodeIco" src="https://www.mbkfw.com/static/image/lazy.gif" class="lazy" original=""https://democj.mbkfw.com/file/image/qrcodelogo.png""/> <div id="qrid"></div> </div> </body> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script> <script> $(function(){ var qrstr = "https://democj.mbkfw.com/"; $('#qrid').qrcode({ width: 120, height: 120, text: qrstr });//指定二维码大小 }) </script> </html>
最终效果