base64-qrcode
v0.0.7
Published
Create Base64-based QR Code. Applicable to Vue, Vue3, React, Angular, Svelte, native JavaScript, Typescript and NodeJS server environments.
Downloads
14
Readme
base64-qrcode
Generate Base64 QR code based on QRCode algorithm.
生成基于QRCode算法的Base64二维码。
- Create Base64-based QR Code. Applicable to Vue, Vue3, React, Angular, Svelte, native JavaScript, TypeScript and NodeJS server environments.
- 创建基于Base64的QR Code。适用于Vue、Vue3、React、Angular、Svelte、原生JavaScript、Typescript和NodeJS服务端环境。
Use
Use npm/yarn/pnpm
pnpm add base64-qrcode
Example
import { drawQRCode } from 'base64-qrcode'
// Output base64 encoded imgData
const base64String = drawQRCode('Hello QRCode!', {
typeNumber: 4,
errorCorrectLevel: 'M',
size: 200
})
console.log(base64String)
API
en-US
- drawQRCode:
Draw Base64 QR code
. - typeNumber:
QR code type
,the default value is 4, and the optional values are 1~40. 1 is 2121, 2 is 2525, 3 is 3333, 4 is 4141, and 40 is a 177*177 matrix. - errorCorrectLevel:
QR code error tolerance rate
, the default value is 'M', and the optional values are 'L', 'M', 'Q', and 'H'. L: 7%, M: 15%, Q: 25%, H: 30% error tolerance (errors can be corrected). The higher the error tolerance, the less likely the QR code is to be damaged, but the less likely it is to be recognized. - size:
QR code image size
, the default value is 300. - backgroundColor:
QR code background color
, the default value is '#ffffff'. - foregroundColor:
QR code foreground color
, the default value is '#000000'. - codePadding:
QR code padding
, the default value is 10.
zh-CN
- drawQRCode:
绘制Base64二维码
的方法。 - typeNumber:
二维码类型
,默认值为4,可选值为1~40。1为2121,2为2525,3为3333,4为4141,40为177*177的矩阵。 - errorCorrectLevel:
二维码容错率
,默认值为'M',可选值为'L'、'M'、'Q'、'H'。 L: 7%, M: 15%, Q: 25%, H: 30% 容错率(错误能被纠正)。容错率越高,二维码越不易损坏,但越不易识别。 - size:
二维码图片大小
,默认值为300。 - backgroundColor:
二维码背景色
,默认值为'#ffffff'。 - foregroundColor:
二维码前景色
,默认值为'#000000'。 - codePadding:
二维码边距
,默认值为10。