Socket
Socket
Sign inDemoInstall

vue-barcode-scanner

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-barcode-scanner

Barcode Scanner Plugin for Vue.js


Version published
Weekly downloads
937
increased by18.61%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Barcode Scanner

============ Barcode Scanner Plugin for Vue.js

Requirement

  • vue

Initiate

Inject plugin to your vue instance by Vue.use then initial it in your component that need to use barcode scanner

Default Injection

import Vue from 'vue'
import VueBarcodeScanner from 'vue-barcode-scanncer'

...

// inject vue barcode scanner
Vue.use(VueBarcodeScanner)

Inject with option

// inject with option (add sound)
// sound will trigger when it's already scanned
// sound setting is false
let options = {
  sound: true, // default is false
  soundSrc : '/static/sound.wav'
}

Vue.use(VueBarcodeScanner, options)


Methods

init

Init method use for add event listener (keydown) for the scanner

this.$barcodeScanner.init(this.onBarcodeScanned)

destroy

Destroy method is for remove the listener when it's unnessessary

this.$barcodeScanner.destroy()

Usage

In your component file (.vue)

  export default {
    created () {
      // Add barcode scan listener and pass the callback function
      this.$barcodeScanner.init(callbackFunction)
    },
    destroyed () {
      // Remove listener when component is destroyed
      this.$barcodeScanner.destroy()
    },
    methods: {
      // Create callback function to received barcode when the scanner is already done
      onBarcodeScanned (barcode) {
        console.log(barcode)
        // do something...
      }
    }
  }

FAQs

Package last updated on 08 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc