Technology Sharing

One of the methods to generate QR code in native mini program

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Effect picture:

Step 1: Download the corresponding package and build it (Tools---》Build npm)

npm install weapp-qrcode --save

Step 2: Declare in wxml pagecanvas

<canvas style="width: 200px; height: 200px;margin:0 auto;" canvas-id="myQrcode"></canvas>

Step 3: Start referencing in the js file 

import drawQrcode from 'weapp-qrcode'

Step 4: Start generating 

  1. drawQrcode({
  2. width: 200,
  3. height: 200,
  4. canvasId: 'myQrcode',
  5. text: 'https://www.baidu.com/'
  6. })

text: is the generated content