微信小程序学习之路 扫一扫

[javascript]  view plain  copy
  1. //index.js  
[javascript]  view plain  copy
  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 = "--result:" + res.result + "--scanType:" + res.scanType + "--charSet:" + res.charSet + "--path:" + 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. }
[css]  view plain  copy
  1. .saoma{  
  2.   height40px;  
  3.   width:110px;  
  4.   line-height40px;  
  5.   margin-leftauto;  
  6.   margin-rightauto;  
  7.   color#fff;  
  8.   background-color#999;  
  9.   text-aligncenter;  
  10. }  
  11. .show{  
  12.   width100%;  
  13.   color#666;  
  14.   background-color#fff;  
  15.   heightauto;  
  16.   
  17. }  

[html]  view plain  copy
  1. <view class="container">  
  2.   <view class="saoma" bindtap="click">点我扫一扫</view>  
  3.   <view class="show">{{show}}</view>  
  4. </view>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值