美文网首页
jquery动态生成二维码

jquery动态生成二维码

作者: 锦锦_jane | 来源:发表于2020-09-09 15:53 被阅读0次
  • 需求:根据当前的网址(携带的参数不一样),生成二维码
  • 方案:使用jq二维码生成插件jquery.qrcode.min.js,生成二维码
  • 步骤:
    1. 下载jquery.qrcode.min.js,打开链接,直接把代码保存为jquery.qrcode.min.js
    2. 引入jq和 jquery.qrcode.min.js
    3. 使用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'//二维码的颜色
    });
    

相关文章

网友评论

      本文标题:jquery动态生成二维码

      本文链接:https://www.haomeiwen.com/subject/drieektx.html