How to use the WeChat applet to identify QR codes using the camera

angryTom
Release: 2020-03-23 12:53:39
Original
7340 people have browsed it

How to use the WeChat applet to identify QR codes using the camera

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=&#39;form-list&#39;>
  <text>二维码内容</text>
  <input type=&#39;text&#39; value=&#39;{{scanCodeMsg}}&#39;></input>
  <image class=&#39;scan&#39; bindtap=&#39;scanCode&#39; src=&#39;/images/scanCode.png&#39; mode=&#39;widthFix&#39;></image>
</view>
Copy after login

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: &#39;成功&#39;,
        duration: 1000
      })
    }
  })
},
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template