Coder Social home page Coder Social logo

pixelverse-llc / strich-vue2-sample Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 36 KB

STRICH Vue 2.x sample code

Home Page: https://strich.io/

License: Creative Commons Zero v1.0 Universal

HTML 6.35% Vue 38.30% CSS 41.92% JavaScript 13.44%
barcode-scanning strich-sdk vue2

strich-vue2-sample's People

Contributors

suzukieng avatar

Stargazers

 avatar

strich-vue2-sample's Issues

configuration not valid

We error configuration not valid

below vue page

import { ref, onUnmounted } from "vue";
import { mapActions, mapGetters } from "vuex";
import { BarcodeReader, StrichSDK } from "@pixelverse/strichjs-sdk";

const detections = ref([]);

export default {
    data() {
        return {
            dataResourcesLoad: []
        }

    },
    async mounted() {
        this.initScan();
    },
    computed: {

    },
    methods: {

        async initScan() {

            // setup STRICH SDK and BarcodeReader
            const licenseKey = 'xxxx';
            StrichSDK.initialize(licenseKey)
                .then(() => {
                    console.log(`STRICH SDK initialized, version: ${StrichSDK.version()}`);

                    // configure the BarcodeReader
                    const configuration = {
                        selector: '#scanner',
                        engine: {
                            symbologies: ['code128']
                        },
                        frameSource: {
                            resolution: 'auto',
                        }
                    };
                    const barcodeReader = new BarcodeReader(configuration);
                    barcodeReader.initialize()
                        .then(() => {

                            // destroy the BarcodeReader when this component is unmounted
                            onUnmounted(() => {
                                barcodeReader.destroy();
                            });

                            barcodeReader.detected = (newDetections) => {
                                detections.value.push(newDetections[0]);
                                console.log(`New scan: [${newDetections[0].data}]`);
                            };
                            barcodeReader.start();
                        });
                })
                .catch(err => {
                    window.alert(`STRICH SDK initialization failed: ${err.message}`);
                });
        }

    }
}

</scr ipt>

    <div id="scanner">
        <!-- STRICH BarcodeReader instantiated here -->
    </div>

    <p>This sample app is based on Vue 2.x</p>
    <ul v-if="detections && detections.length">
        <li v-for="detection in detections">
            {{ detection.data }}
        </li>
    </ul>
    <p v-else>No barcodes scanned yet.</p>



</section>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.