• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號

      孝感風信網(wǎng)絡(luò)科技有限公司微信公眾號

      當前位置:主頁 > 技術(shù)支持 > Javascript/JQuery > QRCode.js:使用 JavaScript 生成二維碼

      QRCode.js:使用 JavaScript 生成二維碼

      時間:2017-05-07來源:風信官網(wǎng) 點擊: 891次

      QRCode.js 是一個用于生成二維碼的 JavaScript 庫。主要是通過獲取 DOM 的標簽,再通過 HTML5 Canvas 繪制而成,不依賴任何庫。
       

      Github 地址:https://github.com/davidshimjs/qrcodejs

      基本用法
      <div id="qrcode"></div>
      <script type="text/javascript">
      new QRCode(document.getElementById("qrcode"), "http://www.runoob.com");  // 設(shè)置要生成二維碼的鏈接
      </script>

      或者使用一些可選參數(shù)設(shè)置:

      var qrcode = new QRCode("test", {
          text: "http://www.runoob.com",
          width: 128,
          height: 128,
          colorDark : "#000000",
          colorLight : "#ffffff",
          correctLevel : QRCode.CorrectLevel.H
      });

      同樣我們可以使用以下方法:

      qrcode.clear(); // 清除代碼
      qrcode.makeCode("http://www.w3cschool.cc"); // 生成另外一個二維碼

      瀏覽器支持

      支持該庫的瀏覽器有:IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, 等。

      實例代碼

      HTML 代碼

      <input id="text" type="text" value="http://www.runoob.com" /><br />
      <div id="qrcode"></div>

      CSS 代碼

      #qrcode {
      width:160px;
        height:160px;
        margin-top:15px;
      }  
       

      JavaScript 代碼

      var qrcode = new QRCode("qrcode");
      
      function makeCode () {      
          var elText = document.getElementById("text");
          
          if (!elText.value) {
              alert("Input a text");
              elText.focus();
              return;
          }
          
          qrcode.makeCode(elText.value);
      }
      
      makeCode();
      
      $("#text").
      on("blur", function () {
          makeCode();
      }).
      on("keydown", function (e) {
          if (e.keyCode == 13) {
              makeCode();
          }
      });
      熱門關(guān)鍵詞: QRCode.js JavaScript 生成二維碼
      欄目列表
      推薦內(nèi)容
      熱點內(nèi)容
      展開
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>