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

  • 相关阅读:
    jenkins log日志过大
    USB Key
    银行应用USB Key身份认证方案
    安全登录认证
    加密和认证
    C#中的委托(Delegate)和事件(Event)
    白皮书、蓝皮书、绿皮书、黄皮书、褐皮书
    DevExpress GridControl使用方法总结
    private protected internal public
    android尺寸问题(转)
  • 原文地址:https://www.cnblogs.com/seasonzone/p/15669205.html
Copyright © 2011-2022 走看看