Home  >  Article  >  WeChat Applet  >  How to use the WeChat applet to identify QR codes using the camera

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

angryTom
angryTomOriginal
2020-03-23 12:53:397164browse

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


  二维码内容
  
  

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!

Statement:
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