调用微信接口扫描二维码
界面文件
1 <view> 2 <view bindtap="click">点我扫一扫</view> 3 <view>{{show}}</view> 4 </view>
js文件
1 //获取应用实例 2 var app = getApp() 3 Page({ 4 data: { 5 show: "", 6 }, 7 8 onLoad: function () { 9 console.log(\'onLoad\') 10 }, 11 click: function () { 12 var that = this; 13 var show; 14 wx.scanCode({ 15 success: (res) => { 16 this.show = "结果:" + res.result + "二维码类型:" + res.scanType + "字符集:" + res.charSet + "路径:" + res.path; 17 that.setData({ 18 show: this.show 19 }) 20 wx.showToast({ 21 title: \'成功\', 22 icon: \'success\', 23 duration: 2000 24 }) 25 }, 26 fail: (res) => { 27 wx.showToast({ 28 title: \'失败\', 29 icon: \'success\', 30 duration: 2000 31 }) 32 }, 33 complete: (res) => { 34 } 35 }) 36 } 37 })
版权声明:本文为ailex原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。