Wechat applet long press to recognize QR code

There are two ways, the first is to directly press and hold on the page to recognize, the second is to preview the picture, and then recognize.

The first implementation: long press and recognize the QR code directly on the page

Add show-menu-by-longpress="{ {true}}" to the image component ;

sample code

<image class="codeImg" src="{
    
    {info.codeImg}}" show-menu-by-longpress="{
    
    {true}}"></image>

The second implementation: After zooming in on the preview image, press and hold to recognize the QR code

<view class="" catchtap="previewImage">
    <image class="codeImg" src="{
    
    {info.codeImg}}"></image>
    <view class="seeTxt">长按识别二维码</view>
</view>

  previewImage: function () {
    var current = 'https://profile.csdnimg.cn/4/6/5/2_qq_35713752.png';
    wx.previewImage({
      urls: [current]
    })
  },

Guess you like

Origin blog.csdn.net/qq_35713752/article/details/129626009