Open tjimenez opened 2 years ago
Same here, typing to use this with Laravel Vite, keep getting errors relating $barcodescanner is not defined:
Entry file:
import VueBarcodeScanner from 'vue3-barcode-scanner'
const app = createApp(App)
app.use(VueBarcodeScanner)
app.mount('#root')
Within my Vue file, within ther script setup:
this.$barcodeScanner.init(onBarcodeScanned)
Any ideas?
Got it, unsure of this is the accepted method, but the following works:
Entry file:
import VueBarcodeScanner from 'vue3-barcode-scanner'
const app = createApp(App)
app.use(VueBarcodeScanner)
app.mount('#root')
Vue component:
<script setup>
import { getCurrentInstance } from 'vue'
function onBarcodeScanned (barcode) {
console.log(barcode)
}
const app = getCurrentInstance()
app.appContext.config.globalProperties.$barcodeScanner.init(onBarcodeScanned)
</script>
Sure there's a more eloquent way to do this, but the above works.
Hi, I've tried for many hours to implement the library without s results.
Can you provide any help?
I'm using vuejs 3 composition api + SFC
Thanks in advance.