Vue-qr is a dedicated Vue 3 component for generating highly customizable QR codes, built upon the Awesome-qr.js library. It offers extensive styling options, including background images (static or GIF), logos, adjustable margins, color control for data blocks and empty spaces, and various error correction levels. The package is currently at version 5.0.3, specifically designed for Vue 3 applications. Historically, version 4.x supports Vue 2, indicating a release cadence tied to Vue's major versions. Its key differentiator is the rich set of visual customization options, enabling developers to embed branded or aesthetically pleasing QR codes directly within their Vue applications, moving beyond basic black-and-white patterns.
npm install vue-qrVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates local registration and basic usage of the VueQr component within a Vue 3 application. It showcases different configurations, including setting text content, custom sizes, incorporating a logo, applying custom colors, handling the 'generated' event, and utilizing various styling props like background colors and logo corner radius.
For Vue 2 projects, you must install version 4.x of the package: `npm install vue-qr@4`. For Vue 3 projects, ensure your `vue` peer dependency in `package.json` is satisfied (e.g., `"vue": "^3.3.0"`).
Ensure your project's browser compatibility targets exclude IE, or implement a fallback solution or warning for users accessing the application via IE.
To use a static background, ensure `gifBgSrc` is not provided or is set to `null`. Use only one of these props at a time for the desired background effect.
If you observe unexpected rendering or require manual control over the generated image data, set `:bindElement="false"` and listen to the `generated` event to access the `dataUrl`.
Ensure you either `import VueQr from 'vue-qr'` and add it to your component's `components` option, or globally register it using `app.use({ install })` after importing `{ install } from 'vue-qr'` in your main application entry point.For Vue 2 projects, install the compatible version 4.x specifically: `npm install vue-qr@4`. For Vue 3 projects, ensure your `package.json` specifies a compatible Vue 3 version (e.g., `"vue": "^3.3.0"`).
When globally registering, use `import { install } from 'vue-qr'` and then `app.use({ install })`. Alternatively, you can use `app.component('VueQr', VueQr)` if you have imported `VueQr` as a named export (`import { VueQr } from 'vue-qr'`).