![How to generate QR code with mini program](https://img.php.cn/upload/article/000/000/020/5e717478c5e1d994.jpg)
How does the mini program generate a QR code?
First open the development tools and create a new small program code snippet, as shown in the figure below
![1584493565901371.png How to generate QR code with mini program](https://img.php.cn/upload/image/997/470/268/1584493565901371.png)
##Then open github, search for weapp-qrcode, and select The first option, as shown in the picture below
![1584493571933406.png How to generate QR code with mini program](https://img.php.cn/upload/image/801/995/507/1584493571933406.png)
Then enter the details interface and download the weapp.qrcode.min.js file, as shown in the picture below
![1584493576196357.png How to generate QR code with mini program](https://img.php.cn/upload/image/189/128/235/1584493576196357.png)
Then copy the weapp.qrcode.min.js file to the mini program directory, as shown in the figure below
![1584493580957157.png How to generate QR code with mini program](https://img.php.cn/upload/image/119/372/113/1584493580957157.png)
Then open the mini program index.js file, import the weapp.qrcode.min.js file at the top, as shown below
![1584493585150415.png How to generate QR code with mini program](https://img.php.cn/upload/image/801/471/237/1584493585150415.png)
Then open the wxml file, declare a canvas, and set a canvas- id, as shown in the figure below
![1584493590205367.png How to generate QR code with mini program](https://img.php.cn/upload/image/745/562/123/1584493590205367.png)
Then call the qrcode method in the index.js file to generate the QR code. The text attribute refers to the content of the QR code, as shown in the figure below
![1584493596600156.png How to generate QR code with mini program](https://img.php.cn/upload/image/590/905/142/1584493596600156.png)
Finally run the applet and you can see the generated QR code. Scan and read the text content, as shown in the figure below
![1584493603373418.png How to generate QR code with mini program](https://img.php.cn/upload/image/411/127/918/1584493603373418.png)
The above is the detailed content of How to generate QR code with mini program. For more information, please follow other related articles on the PHP Chinese website!