当前位置:网站首页>Generate detailed API and parameters of QR code using qrcodejs2

Generate detailed API and parameters of QR code using qrcodejs2

2022-06-22 22:32:00 _ Baby grut

Use qrcodejs2 Generate qr code

install qrcodejs2

cnpm install qrcodejs2 --save

Use qrcodejs2

The page introduce

import QRCode from 'qrcodejs2'

Page TAB

<div id="qrcode" ref="qrcode"></div>

You can make ⽤ id perhaps ref, It is suggested that ⽤ ref, Because ⽤ vue Frame control virtual Dom The right choice is simple ⽅ then

createQRcode(WIDTH, id, text) {
  let long = document.documentElement.clientWidth * (WIDTH / 375)
  new QRCode(id, {
    width: long,
    height: long,
    text: text,
    correctLevel : QRCode.CorrectLevel.L
  });
  // correctLevel  Fault tolerance level , Can be set to :
  // QRCode.CorrectLevel.L
  // QRCode.CorrectLevel.M
  // QRCode.CorrectLevel.Q
  // QRCode.CorrectLevel.H
  // L - M - Q - H  The code density is getting higher and higher , Default not set yes  H
},
// this.createQRcode(132, `qrcode`, `${this.DOMAIN}`);

Parameter description

new QRCode(element, option)
name The default value is explain
element- Displays the element of the QR code or the name of the element ID
option Parameter configuration

Options

name The default value is explain
width256 The width of the image
height256 Height of the image
typeNumber4
colorDark"#000000" The foreground
colorLight"#ffffff" Background color
correctLevelQRCode.CorrectLevel.L

Fault tolerance level , Can be set to :

QRCode.CorrectLevel.L

QRCode.CorrectLevel.M

QRCode.CorrectLevel.Q

QRCode.CorrectLevel.H

The density of generated codes from top to bottom is getting higher and higher

L - M - Q - H

Events

name explain
makeCode(text) Set QR code content
clear() Clear QR code .( Only if it doesn't support Canvas It works under the browser of )

resources  

qrcodejs2 - npmJavsacript QRCode for all browsers. Latest version: 0.0.2, last published: 7 years ago. Start using qrcodejs2 in your project by running `npm i qrcodejs2`. There are 166 other projects in the npm registry using qrcodejs2.https://www.npmjs.com/package/qrcodejs2

原网站

版权声明
本文为[_ Baby grut]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221825099999.html

随机推荐