Closed Patrick777777 closed 5 years ago
Implementation is pretty straightforward:
<script>
import { fromNativeSource } from 'tns-core-modules/image-source'
import ZXing from 'nativescript-zxing'
export default {
name: 'MyComponent',
data () {
return {
imageSource: null
}
},
beforeMount () {
const zx = new ZXing()
const barcode = zx.createBarcode({ encode: 'some-text', height: 200, width: 200, format: ZXing.QR_CODE })
this.imageSource = fromNativeSource(barcode)
}
}
</script>
Now imageSource
can be used as an imageSource
attribute for Image
element inside templates.
<template>
<Image
:imageSource="imageSource"
/>
</template>
thanks for the help, i got it working 👍
@Patrick777777 Awesome! Please, don't forget to close the issue.
It could be great to add this code snippet to the demo folder https://github.com/NathanaelA/nativescript-zxing/tree/master/demo :-)
@oliverpool - It would be awesome if someone wanted to create a NS-Vue demo. I love PR's. ;-)
Hi, I've tried this plugin with NativeScript-Vue. I followed the instructions in the documentation, but I can't get it to work, I keep getting this error: "Cannot read property 'BarcodeFormat' of undefined". Is there any way to use this plugin with NativeScript-Vue?