Skip to content

Commit

Permalink
Add vue-ref to qrscan (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorWinberg authored Apr 5, 2022
1 parent eaac7fc commit cd0aeb8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/components/QRScanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<i v-else class="far fa-bolt"></i>
</div>
</div>
<div class="qrscan"><video id="qrscan"></video></div>
<div class="qrscan"><video id="qrscan" ref="qrscan"></video></div>
</div>
</template>

Expand Down Expand Up @@ -66,10 +66,11 @@ export default Vue.extend({
const devices = await navigator.mediaDevices.enumerateDevices();
const cameras = devices.filter(device => device.kind === "videoinput");
const camera = cameras[cameras.length - 1];
if (!camera) return;
const { qrscan } = this.$refs;
if (!camera || !qrscan) return;
this.scanner = new QRScanner(
document.getElementById("qrscan"),
qrscan,
qrcode => {
if (qrcode) {
this.handleQR(qrcode);
Expand Down

0 comments on commit cd0aeb8

Please sign in to comment.