Skip to content

Commit 433814f

Browse files
committed
need to reuse pScanner
1 parent 1b14aec commit 433814f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

1.hello-world/5.read-video-vue/src/components/ImgDecode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
methods: {
1515
async decodeImg(e) {
1616
try {
17-
const reader = await (this.pReader = BarcodeReader.createInstance());
17+
const reader = await (this.pReader = this.pReader || BarcodeReader.createInstance());
1818
let results = await reader.decode(e.target.files[0]);
1919
for(let result of results){
2020
alert(result.barcodeText);

1.hello-world/5.read-video-vue/src/components/VideoDecode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636
},
3737
async mounted() {
3838
try {
39-
const scanner = await (this.pScanner = BarcodeScanner.createInstance());
39+
const scanner = await (this.pScanner = this.pScanner || BarcodeScanner.createInstance());
4040
await scanner.setUIElement(this.$el);
4141
scanner.onFrameRead = (results) => {
4242
for (let result of results) {

0 commit comments

Comments
 (0)