zoukankan      html  css  js  c++  java
  • 根据URL地址生成二维码

    前提:之前用了别人网站的api来实现生成二维码,亮哥说不行,这样太依赖别人的,真的实现不了才这么做。
    这次,我就选择了别人开源的文件进行调用,只要加载一个小js文件,再用它的语法即可。

     

    下载qrcodejs URL:http://davidshimjs.github.io/qrcodejs/

    在页面中引用jq和qrcodejs两个文件

    html页面

        <html>
            <head>
                <title>demo</title>
            </head>
            
             <script type="text/javascript" src="./js/jquery.js"></script>
             <script type="text/javascript" src="./js/qrcode.min.js"></script>
            
            
            <body>
         
                <div id="qrcode"></div>
         
                <input type="button" value="按钮" id="hit"/>
         
            </body>
            <script type="text/javascript">
               var qrcode = new QRCode("qrcode", {  
                text: 'http://www.baidu.com',   //URL地址
                 260,
                height: 260,
                colorDark: '#000',    //二维码颜色
                colorLight: "#ffffff"  //背景颜色
            });
            $('#hit').click(function(){
                 qrcode.clear(); // clear the code.
                 qrcode.makeCode("http://naver.com"); // make another code.
            });
           
         
           </script>
        </html>

     

    "qrcode" 为一个标签的id,执行后会在标签中插入一个cansave和img标签

    img的src为 base64值
    ————————————————
    版权声明:本文为CSDN博主「韩师学子--小倪」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/xiao__jia__jia/article/details/89045206

  • 相关阅读:
    C#中IPAddress转换成整型int
    没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))
    VB.NET或C#报错:You must hava a license to use this ActiveX control.
    c#几种随机数组和数组乱序
    C#封装的websocket协议类
    VB生成条形码(EAN-13)
    VB控件间的拖放
    VB用API模拟截屏键PrintScreen
    VB读写进程的内存
    几个VB常见又内涵的错误
  • 原文地址:https://www.cnblogs.com/seasonzone/p/15669205.html
Copyright © 2011-2022 走看看