When using Vue to do mobile apps, call the camera to scan the QR code

Source: Internet
Author: User

Now the front-end technology development is fast, the front-end can do the app, then the project, you will also encounter some functions called Android phone base, such as the call camera, complete scanning QR code function

Let me explain to you the process of invoking this feature in my project.

First we need an intermediate frame,hbuilder

http://www.html5plus.org/doc/zh_cn/accelerometer.html This is html5+ 's document address, we found the barcode module,

There are so many, and then we look down

Find this piece of code

<! DOCTYPE html>

This code, must be placed in our Vue index.html page, do not ask me why, I do not know, anyway is to the overall

After the extension API has finished loading, call the Onplusready callback function Document.addeventlistener ("Plusready", Onplusready, false);//The extension API is loaded, Extension Apifunction Onplusready () {var e = document.getElementById ("Scan") can now be called Normally, E.removeattribute ("Disabled");} var scan = null;

I wrote this, and this code was put in methods.

Startrecognize () {scan = new Plus.barcode.Barcode (' bcid '); scan.onmarked = onmarked;       This.startscan}  Startscan () {    scan.start ();}  

If you try not to, then in the Startrecognize function to add a settimeout, delay a 200ms, I try to be able to use, scan success will have a alert, this can be changed to scan after successful function or you want to do things.

When using Vue to do mobile apps, call the camera to scan the QR code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.