Giter VIP home page Giter VIP logo

jrqrcode's Introduction

二维码js生成库

把字符串生成二维码,并以Base64 URL形式输出。 支持白色二维码,即反色二维码。

兼容性

插件使用了H5的canvas特性进行二维码绘制,最后输出base64 url,因此本插件要求运行环境支持canvas特性即可。

安装

npm install jr-qrcode

插件引用

传统引用

<script type="text/javascript" src="dist/jr-qrcode.js"></script>

<script>
  var imgBase64 = jrQrcode.getQrBase64('hello world');
</script>

模块化引用(比如:webpack)

// 方法1:全局引用(window.jrQrcode)
require('jr-qrcode');

// 方法2:变量引用
var jrQrcode = require('jr-qrcode');

// 模块方法调用,传入字符串,获取 base64 编码的图片 URL
var imgBase64 = jrQrcode.getQrBase64('hello world');

用法

var imgBase64 = jrQrcode.getQrBase64(text, options);

/**
@param: text: 要生成二维码的字符,支持中文
@param: options: {
  padding       : 10,   // 二维码四边空白(默认为10px)
  width         : 256,  // 二维码图片宽度(默认为256px)
  height        : 256,  // 二维码图片高度(默认为256px)
  correctLevel  : QRErrorCorrectLevel.H,    // 二维码容错level(默认为高)
  reverse       : false,        // 反色二维码,二维码颜色为上层容器的背景颜色
  background    : "#ffffff",    // 二维码背景颜色(默认白色)
  foreground    : "#000000"     // 二维码颜色(默认黑色)
}
@return: 生成的二维码Base64 URL
*/

二维码容错级别

QRErrorCorrectLevel = {
  L : 1,
  M : 0,
  Q : 3,
  H : 2
};

Use cases

If you are using jrQrcode in production, just tell us.

jrqrcode's People

Contributors

diamont1001 avatar lanceli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.