Dynamsoft / barcode-reader-javascript

Dynamsoft Barcode Reader JavaScript SDK for package managers. PDF417, QR Code, DataMatrix, MaxiCode and more are supported.
https://www.dynamsoft.com/barcode-reader/sdk-javascript/
Other
169 stars 111 forks source link

Ionic Vue Unexpected token '<' #94

Closed tigohenryschultz closed 2 years ago

tigohenryschultz commented 2 years ago

image

My code:

  import DBR from 'dynamsoft-javascript-barcode';

export default {
    name: 'TgDynamsoftTest',

    methods: {
      async scan() {
        DBR.BarcodeReader.productKeys = "hidden";

        let scanner = await DBR.BarcodeScanner.createInstance();
        await this.scanner.setUIElement(document.getElementById('scannerUI'));
        scanner.onFrameRead        = this.frameRead;
        scanner.onUnduplicatedRead = this.onUnduplicatedRead;
        await scanner.show();
        this.scanner = scanner;
      },

      frameRead(results) {
        console.log('frame read:', results);
      },

      onUnduplicatedRead(txt, result) {
        console.log('txt:', txt, ' result:', result);
      }
    }
  }
Keillion commented 2 years ago

I guess you did not set engineResourcePath appropriately .

https://github.com/Dynamsoft/javascript-barcode/blob/master/example/web/vue/src/dbr.js

Try to check network tab in developer tools.

tigohenryschultz commented 2 years ago

I guess you did not set engineResourcePath appropriately .

https://github.com/Dynamsoft/javascript-barcode/blob/master/example/web/vue/src/dbr.js

Try to check network tab in developer tools.

Worked, thanks. Should throw an error if the user leaves that field null lol

Keillion commented 2 years ago

@tigohenryschultz Haha, you are right.

By default it will try to find worker.js in the same folder of the dbr.js. In pure js it works. But in framework like vue we most set it manully.

I'm think of detecting framework or just guessing. Make the error message more friendly.