- 需求:根据当前的网址(携带的参数不一样),生成二维码
- 方案:使用jq二维码生成插件jquery.qrcode.min.js,生成二维码
- 步骤:
- 下载jquery.qrcode.min.js,打开链接,直接把代码保存为jquery.qrcode.min.js
- 引入jq和 jquery.qrcode.min.js
- 使用qrcode
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
// 动态生成二维码 // var qrcodeUrl = window.location.href;//二维码链接 // console.log(qrcodeUrl); var qrcodeUrl = 'https://www.jianshu.com/p/9a37ba21defa';//二维码链接 $('#qrcode').qrcode({ width: 200, height:200, text: qrcodeUrl, background:'#ffffff',//二维码的背景色 foreground:'#0058d6'//二维码的颜色 });
网友评论