插件地址 http://static.runoob.com/assets/qrcode/qrcode.min.js ,网页直接打开,然后ctrl+s保存到本地。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <button id="btn">分享</button> <div id="qrcode" style="display: none;"></div> <script src="jquery.min.js"></script> <script src="qrcode.min.js"></script> <script> var qrcode = new QRCode(document.getElementById("qrcode"), { width : 200, height : 200 }); var urlPath = window.location.href; qrcode.makeCode(urlPath); $("#btn").mouseover(function(){ $('#qrcode').show(); }).mouseout(function(){ $('#qrcode').hide(); }) </script> </body> </html>
效果截图: