Description:
This is the upgraded version of the gruhn’s vue-qrcode-reader that allows you to decode/parse QR code in the Vue.js 3 powered apps.
How to use it:
1. Import and register the QR Code Reader.
// globally import { createApp } from 'vue'; import App from './App.vue' import QrReader from 'vue3-qr-reader'; const app = createApp(App); app.use(QrReader); app.mount('#app') // Locally import { QrStream, QrCapture, QrDropzone } from 'vue3-qr-reader'; export default { components: { QrStream, QrCapture, QrDropzone }, };
2. Create a file upload field to scan all files you select.
<qr-capture @decode="onDecode" class="mb"></qr-capture> <div class="result"> Result: {{data}} </div>
export default defineComponent({ name: 'QrCaptureExample', components: { QrCapture }, setup() { const state = reactive({ data: null }) function onDecode(data) { state.data = data } return { ...toRefs(state), onDecode } } });
3. Access the device camera and continuously scans the incoming frame.
<div class="stream"> <qr-stream @decode="onDecode" class="mb"> <div style="color: red;" class="frame"></div> </qr-stream> </div> <div class="result"> Result: {{data}} </div>
export default defineComponent({ name: 'QrStreamExample', components: { QrStream }, setup() { const state = reactive({ data: null }) function onDecode(data) { state.data = data } return { ...toRefs(state), onDecode } } });
4. Create a drag’n’drop zone to scan all files you dropped.
<qr-dropzone class="dropzone mb" @decode="onDecode"> Drop image here. </qr-dropzone> <div class="result"> Result: {{data}} </div>
export default defineComponent({ name: 'QrDropzoneExample', components: { QrDropzone }, setup() { const state = reactive({ data: null }) function onDecode(data) { state.data = data } return { ...toRefs(state), onDecode } } });
Preview:
Download Details:
Author: HJ29
Live Demo: https://hj29.github.io/vue3-qr-reader/
Download Link: https://github.com/HJ29/vue3-qr-reader/archive/master.zip
Official Website: https://github.com/HJ29/vue3-qr-reader
Install & Download:
# Yarn
$ yarn add vue3-qr-reader
# NPM
$ npm i vue3-qr-reader --save