1. 程式人生 > >微信小程式呼叫掃一掃

微信小程式呼叫掃一掃

  1. //獲取應用例項 var app = getApp()Page({ data: { show: "", },
    onLoad: function () { console.log('onLoad') }, click: function () { var that = this; var show; wx.scanCode({ success: (res) => { this.show = "--result:" + res.result + "--scanType:" + res.scanType + "--charSet:"
    + res.charSet + "--path:" + res.path; that.setData({ show: this.show }) wx.showToast({ title: '成功', icon: 'success', duration: 2000 }) }, fail: (res) => { wx.showToast({ title: '失敗', icon: 'success', duration: 2000
    }) }, complete: (res) => { } }) }}) <view class="container"> <view class="saoma" bindtap="click">點我掃一掃</view> <view class="show">{{show}}</view> </view>