Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Process #34

Open
tjimenez opened this issue Jan 20, 2022 · 2 comments
Open

Integration Process #34

tjimenez opened this issue Jan 20, 2022 · 2 comments

Comments

@tjimenez
Copy link

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 <script setup>

Thanks in advance.

@ultrono
Copy link

ultrono commented Oct 10, 2022

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?

@ultrono
Copy link

ultrono commented Oct 10, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants