Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Barcode scanner integration
- **Problem:** can’t access barcode scanner plugin methods from Vue
- If we can’t figure out how to surmount, may need to abandon Vue altogether & go w/ another approach
- Reproduce:
- 1. Good starter (framework7): https://blog.toast38coza.me/building-a-mobile-app-with-vuejs-cordova-webpack-and-framework-7/
- 2. Barcode scanner Cordova plugin (install w/ cordova command): https://www.npmjs.com/package/cordova-plugin-barcodescanner
- 3. Attempt to invoke this method:
- ```js
- cordova.plugins.barcodeScanner.scan(
- function (result) {
- alert("We got a barcode\n" +
- "Result: " + result.text + "\n" +
- "Format: " + result.format + "\n" +
- "Cancelled: " + result.cancelled);
- },
- function (error) {
- alert("Scanning failed: " + error);
- }
- );
- ```
- ## Issues/Posts:
- * https://github.com/AppointmentGuru/webpack-mobile-f7/issues/4
- * https://forum.vuejs.org/t/how-to-import-barcodescanner-in-vuejs-component/17608/6
- * https://github.com/kartsims/vue-cordova/issues/11
- * http://forum.quasar-framework.org/topic/599/cordova-cordova-plugin-qrscanner-plugin-preview-not-showing
- ## Side-Issue: vue-cordova
- (Note: There may be a way to sidestep Vue-Cordova altogether)
- Vue-Cordova: http://kartsims.github.io/vue-cordova/vue-cordova/
- Vue-cordova exposes a cordova obj (ex Vue.cordova.blahblah) & plugins on global “Vue” but from source it looks like user needs to manually add support plugins (unsuccessful so far):
- * https://github.com/kartsims/vue-cordova/issues/11
- * https://stackoverflow.com/questions/43629684/add-cordova-plugins-to-vue-cordova
- *
- Idea alluded to by author in closed issue #11 (couldn’t get to work, should be “mounted” of component?)
- ```js
- Vue.cordova.on('deviceready', function () {
- cordova.plugins.barcodeScanner...
- })
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement