随笔 - 315  文章 - 1  评论 - 12  阅读 - 24万

qrcode生成二维码

html

<div id="qrcode" class="qrcode"></div>

js

复制代码
  let _url = "https://test1561.chot.cn/web/?page=positionDetail&id="+_item.id+"&total="+ _this.pageList.total;
            /* 生成二维码 */
            setTimeout(()=>{
                $("#qrcode").qrcode({
                    text: _url, //设置二维码内容
                    render: "table", //设置渲染方式
                    width:200, //设置宽度,默认生成的二维码大小是 256×256
                    height: 200, //设置高度
                    typeNumber: -1, //计算模式
                    background: "#ffffff", //背景颜色
                    foreground: "#000000" //前景颜色
                });
                let _child = $("#qrcode").children();
                if(_child.length>1){
                    $("#qrcode").children().eq(0).remove(); // 删除已有的,否则二维码会叠加
                }
            },200);
复制代码

  注意:必须使用延时,否则首次无法生成二维码

posted on   小虾米吖~  阅读(355)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
历史上的今天:
2019-07-26 响应式布局

点击右上角即可分享
微信分享提示