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