Hello Geeks ,I was working for the generation of QRCode in LWC which is the new feature of Salesforce from the Spring '19 release. We all use the API's for this purpose as they are very simple and easy to implement. I too did the same for generation of QR Code in my LWC Component. But what if they get deprecated..? So, for solving this I tried creating ES6 code for the generation of QR-Code in the Salesforce Lightning Web Components.
You just need to pass a String for which the QR-Code will be generated and will be displayed on the UI of your component.
These are the following simple steps through which you can generate the QR-Code.
- Create an LWC component.
- Add a module to the component named qrcode.js in the same folder of your LWC component. Paste the below code in a qrcode.js fileCopy the qrcode.js file from GitHub file qrcode.js
- Import the Module added in the components .js file to your components js file as shown in the below snippet.
- Now, at last add the below code to your HTML file
There you go... You have successfully created the QR-Code in your LWC component....
The complete code can be referred from Github