-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathApp.vue
More file actions
67 lines (57 loc) · 1.93 KB
/
App.vue
File metadata and controls
67 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<script setup lang="ts">
import { onMounted } from 'vue';
import { BarcodeScanner } from 'dynamsoft-barcode-reader-bundle';
import vueLogo from "./assets/vue.svg";
onMounted(() => {
// Configuration object for initializing the BarcodeScanner instance
const config = {
license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key
container: ".barcode-scanner-view", // Specify where to render the scanner UI
// Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view.
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.3000/dist/",
// Specify custom paths for the engine resources
engineResourcePaths: {
rootDirectory: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.3000/dist/",
},
}
// Create an instance of the BarcodeScanner with the provided configuration
const barcodeScanner = new BarcodeScanner(config);
// Launch the scanner; once a barcode is detected, display its text in an alert
barcodeScanner.launch().then((result) => {
alert(result.barcodeResults[0].text);
});
})
</script>
<template>
<div class="barcode-scanner-hello-world-page">
<div class="barcode-scanner-title">
<h2 class="barcode-scanner-title-text">Hello World for Vue</h2>
<img class="barcode-scanner-title-logo" :src="vueLogo" alt="logo"></img>
</div>
<!-- This div will host the barcode scanner's camera view -->
<div class="barcode-scanner-view"></div>
</div>
</template>
<style scoped>
.barcode-scanner-hello-world-page {
width: 100%;
height: 100%;
text-align: center;
}
.barcode-scanner-title {
height: 90px;
display: flex;
justify-content: center;
align-items: center;
padding: 20px 0;
}
.barcode-scanner-title .barcode-scanner-title-logo {
width: 30px;
height: 30px;
margin-left: 10px;
}
.barcode-scanner-view {
width: 100%;
height: calc(100% - 90px);
}
</style>