Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fourdim/wechat-miniapp-qrcode

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fourdim/wechat-miniapp-qrcode

Dynamically generated QR codes for Wechat Miniapps.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

wechat-miniapp-qrcode

Dynamically generated QR codes for Wechat Miniapps.

Notice: This library is only compatible with the WeChat mini program framework as it uses the WeChat native APIs.

If you are looking for the QR code generator for modern browsers, you may refer to lrsjng/kjua.

Requirements

  • Mini program base library version >= 2.9.0

Usage

  <!-- canvas.wxml -->
  <canvas type="2d" id="myCanvas"></canvas>
  <!-- need 2d type -->
  <!-- id but not canvas-id -->
// canvas.js
import genQrcode from '@fourdim/wechat-miniapp-qrcode'

const query = wx.createSelectorQuery()
query.select('#myCanvas')
    .fields({ node: true, size: true })
    .exec((res) => {
        genQrcode(res[0].node, {text: 'Hello'})
    })

The available options and their default values are:

{
    // render method: 'canvas' or 'image'
    render: 'canvas',

    // render pixel-perfect lines
    crisp: true,

    // minimum version: 1..40
    // refer to https://kazuhikoarase.github.io/qrcode-generator/js/demo/ for more
    minVersion: 1,

    // error correction level: 'L', 'M', 'Q' or 'H'
    ecLevel: 'L',

    // size in pixel
    size: 200,

    // pixel-ratio, null for wx.getSystemInfoSync().pixelRatio
    ratio: null,

    // code color
    fill: '#333',

    // background color
    back: '#fff',

    // content
    text: 'no text',

    // roundend corners in pc: 0..100
    rounded: 0,

    // quiet zone in modules
    quiet: 0,

    // modes: 'plain', 'label' or 'image'
    mode: 'plain',

    // label/image size and pos in pc: 0..100
    mSize: 30,
    mPosX: 50,
    mPosY: 50,

    // label
    label: 'no label',
    fontname: 'sans',
    fontcolor: '#333',

    // image element
    image: null
}

Credits

LICENSE

MIT

Trademark

QR Code is a registered trademark of DENSO WAVE INCORPORATED.

Keywords

FAQs

Package last updated on 25 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc