qrcode
QRCode 是一个用于生成二维码的 JavaScript 库。主要是通过获取 DOM 的标签,再通过 HTML5 Canvas 绘制而成,不依赖任何库。
安装方式
npm install --save qrcode
npm install @types/qrcode //This package contains type definitions for qrcode
Canvas方法
@types/qrcode中的对方法 toCanvas解释
interface QRCodeRenderersOptions extends QRCodeOptions {
/**
* Define how much wide the quiet zone should be.
* Default: 4
*/
margin?: number;
/**
* Scale factor. A value of 1 means 1px per modules (black dots).
* Default: 4
*/
scale?: number;
/**
* Forces a specific width for the output image.
* If width is too small to contain the qr symbol, this option will be ignored.
* Takes precedence over scale.