├── .gitignore ├── src ├── index.js └── components │ ├── ImageBarcodeReader.vue │ └── StreamBarcodeReader.vue ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import ImageBarcodeReader from "./components/ImageBarcodeReader.vue"; 2 | import StreamBarcodeReader from "./components/StreamBarcodeReader.vue"; 3 | 4 | export { ImageBarcodeReader, StreamBarcodeReader }; 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-barcode-reader", 3 | "version": "1.0.3", 4 | "description": "Vue barcodes and QR codes scanner", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://olefirenko@github.com/olefirenko/vue-barcode-reader.git" 12 | }, 13 | "keywords": [ 14 | "vue", 15 | "barcode", 16 | "qrcode", 17 | "zxing" 18 | ], 19 | "author": "olefirenko ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/olefirenko/vue-barcode-reader/issues" 23 | }, 24 | "homepage": "https://github.com/olefirenko/vue-barcode-reader#readme", 25 | "dependencies": { 26 | "@zxing/library": "^0.19.1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/components/ImageBarcodeReader.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 41 | -------------------------------------------------------------------------------- /src/components/StreamBarcodeReader.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 54 | 55 | 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Barcode and QR code scanner 2 | 3 | [![npm version](https://badgen.net/npm/v/vue-barcode-reader)](https://www.npmjs.com/package/vue-barcode-reader) [![sponsored_by](https://badgen.net/badge/sponsored%20by/%F0%9F%A4%96Easy-Peasy.AI/f2a)](https://Easy-Peasy.AI/?utm_source=npm&utm_medium=badge&utm_campaign=vue_barcode_reader) 4 | 5 | A Vue.js set of components to scan (or upload images) barcodes and QR codes. 6 | 7 | ## Benefits 8 | 9 | - Can scan both barcodes and QR codes 10 | - Uses [ZXing](https://github.com/zxing-js/library) ("zebra crossing"), an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. 11 | 12 | ## Demo 13 | 14 | [Demo repository](https://github.com/olefirenko/vue-barcode-reader-example) | [Codesandbox](https://codesandbox.io/s/vue-barcode-reader-demo-guj3f) | [Vercel](https://vue-barcode-reader-example-2iiz1fhbf-olefirenko.vercel.app/) | [Netlify](https://stupefied-meitner-58f299.netlify.app/) 15 | 16 | Or you can check the library in action on the website [parceltrackingapp.com](https://parceltrackingapp.com/en). 17 | 18 | ## Installation 19 | 20 | The easiest way to use Vue Barcode Reader is to install it from **npm** or **yarn**. 21 | 22 | ```sh 23 | npm install vue-barcode-reader --save 24 | ``` 25 | 26 | Or 27 | 28 | ```sh 29 | yarn add vue-barcode-reader 30 | ``` 31 | 32 | ### Vue 2.0 support 33 | 34 | For Vue 2.0 compatible version please use the `vue-barcode-reader@0.0.3`. 35 | 36 | ### TypeScript 37 | 38 | There are type definitions available for those who work with TypeScript. 39 | 40 | ```sh 41 | npm install @types/vue-barcode-reader --save-dev 42 | ``` 43 | 44 | Or 45 | 46 | ```sh 47 | yarn add -D @types/vue-barcode-reader 48 | ``` 49 | 50 | ## Usage 51 | 52 | The Vue Barcode Reader works out of the box by just including it. 53 | 54 | ### Using Video Camera 55 | 56 | Once a stream from the users camera is loaded, it's displayed and continuously scanned for barcodes. Results are indicated by the decode event. 57 | 58 | ```js 59 | import { StreamBarcodeReader } from "vue-barcode-reader"; 60 | ``` 61 | 62 | In your template you can use this syntax: 63 | 64 | ```html 65 | 66 | ``` 67 | 68 | ### Scanning from Image 69 | 70 | The component renders to a simple file picker input element. Clicking opens a file dialog. On supporting mobile devices the camera is started to take a picture. The selected images are directly scanned and positive results are indicated by the `decode` event. 71 | 72 | ```js 73 | import { ImageBarcodeReader } from "vue-barcode-reader"; 74 | ``` 75 | 76 | In your template you can use this syntax: 77 | 78 | ```html 79 | 80 | ``` 81 | 82 | ```html 83 | methods: { onDecode (result) { console.log(result) } } 84 | ``` 85 | 86 | ## Events 87 | 88 | The library emits the following events: 89 | 90 | ### loaded 91 | 92 | When the libraty is loaded and the camera is ready to scan 93 | 94 | ### decode 95 | 96 | When a barcode or QR code is scanned. The result is passed as a parameter to the event handler. The result is the text encoded in the barcode or QR code. 97 | 98 | ### result 99 | 100 | When a barcode or QR code is scanned. The result is passed as a parameter to the event handler. The result is the object with the following properties: 101 | --------------------------------------------------------------------------------