How does the WeChat applet use the camera to identify QR codes
The WeChat applet provides us with an API: wx.scanCode(Object object ), you can use it to call the code scanning function to identify the QR code.
Recommended learning: Small program development
The method of using a camera to identify QR codes is as follows:
1. First write wxml file, add a button that calls the code scanning function
<view class='form-list'> <text>二维码内容</text> <input type='text' value='{{scanCodeMsg}}'></input> <image class='scan' bindtap='scanCode' src='/images/scanCode.png' mode='widthFix'></image> </view>
2, then write the click event of the button, and output the recognized QR code content.
data: { scanCodeMsg: "", }, scanCode: function() { var that = this; wx.scanCode({ //扫描API success(res) { //扫描成功 console.log(res) //输出回调信息 that.setData({ scanCodeMsg: res.result }); wx.showToast({ title: '成功', duration: 1000 }) } }) },
PHP Chinese website, a large number of free MySQL video tutorials, welcome to learn!
The above is the detailed content of How to use the WeChat applet to identify QR codes using the camera. For more information, please follow other related articles on the PHP Chinese website!