Vue QR Code Component

2.2.2 · active · verified Sun Apr 19

vue-qrcode is a Vue.js component designed for generating QR codes directly within Vue applications. It serves as a declarative wrapper around the popular `qrcode` library (github.com/soldair/node-qrcode), abstracting away the complexities of direct canvas or SVG manipulation. The package is currently at version 2.2.2 and maintains an active development cycle, with recent patch and minor releases addressing fixes and new features. It differentiates itself by offering a Vue-idiomatic interface to robust QR code generation, supporting a wide array of customization options including version, error correction level, quiet zone margin, scaling, exact width, and customizable dark and light module colors. It's compatible with both Vue 2.7+ and Vue 3.0+ environments, making it suitable for modern Vue projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate the VueQrcode component into a Vue SFC, bind a value, pass options, and capture the generated data URL via the `change` event.

<template>
  <vue-qrcode
    value="https://www.1stg.me"
    :options="{ errorCorrectionLevel: 'H' }"
    @change="onDataUrlChange"
  />
</template>
<script>
import VueQrcode from 'vue-qrcode'

export default {
  data() {
    return {
      dataUrl: null,
      qrValue: 'https://www.example.com/qr-data'
    }
  },
  components: {
    VueQrcode,
  },
  methods: {
    onDataUrlChange(dataUrl) {
      console.log('Generated Data URL:', dataUrl)
      this.dataUrl = dataUrl
    },
    updateQrValue() {
      this.qrValue = `https://new-data.com/${Date.now()}`
    }
  },
  mounted() {
    // Simulate updating QR code value after some time
    setTimeout(this.updateQrValue, 5000)
  }
}
</script>

view raw JSON →