小程序,调用微信扫一扫功能

微信小程序调用扫一扫,将所得的信息展示到页面中

wxml文件:

<view bindtap='scancode'>
    <text class='texts'>(点击扫一扫) </text>
</view>
<view>{{result}}</view>


js文件:

Page({
  data: {
    result: "",
  },
  scancode: function () {
    let that = this;
    let result;
    wx.scanCode({
      success: (res) => {
        this.result = res.result;
        that.setData({
          result: this.result
        })
      }
    })
  },
})

猜你喜欢

转载自blog.csdn.net/qq_35410544/article/details/83819038