Son photo town floor hee hee
Demand background
Recently, I received a request to use the iPad browser to scan the code
Because the author is engaged in the real estate industry, the most used device is iPad, which is more convenient ~ ~ ~ no more nonsense, serve food!
After a lot of research [Baidu Google search] finally decided to use QR-scanner this plug-in NPM document link: www.npmjs.com/package/qr-… Github link: github.com/nimiq/qr-sc… Demo link: qrcodescan-in
Note that HTTP does not invoke the camera during debugging, requiring HTTPS
The framework is vUE, the first step
npm install --save qr-scanner
Copy the code
The second step
import QrScanner from 'qr-scanner';
Copy the code
The third step
WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH = WORKER_PATH Add qr-scanner-worker.min.js to public so that packaging won’t change it, and then import
QrScanner.WORKER_PATH = './qr-scanner-worker.min.js';
Copy the code
The fourth step
Create an instance of qrScanner and start the scanner according to the documentation API
Const qrScanner = new qrScanner (document.querySelector('video'), result => {console.log(' printed ', }) qrscanner.start ();}) qrScanner.Copy the code
This time you can see the results of scanning the QR code in the browser