微信小程序学习之路 扫一扫
2018-03-14 01:37
423 查看
[javascript] view
plain copy
//index.js
[javascript] view
plain copy
//获取应用实例
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) =>{
}
})
}
[css] view
plain copy
.saoma{
height: 40px;
width:110px;
line-height: 40px;
margin-left: auto;
margin-right: auto;
color: #fff;
background-color: #999;
text-align: center;
}
.show{
width: 100%;
color: #666;
background-color: #fff;
height: auto;
}
[html] view
plain copy
<view class="container">
<view class="saoma" bindtap="click">点我扫一扫</view>
<view class="show">{{show}}</view>
</view>
plain copy
//index.js
[javascript] view
plain copy
//获取应用实例
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) =>{
}
})
}
[css] view
plain copy
.saoma{
height: 40px;
width:110px;
line-height: 40px;
margin-left: auto;
margin-right: auto;
color: #fff;
background-color: #999;
text-align: center;
}
.show{
width: 100%;
color: #666;
background-color: #fff;
height: auto;
}
[html] view
plain copy
<view class="container">
<view class="saoma" bindtap="click">点我扫一扫</view>
<view class="show">{{show}}</view>
</view>
相关文章推荐
- 微信小程序学习之路(一)
- 微信小程序学习之路04-简易的计算器
- 微信小程序小白开发学习之路———视图与渲染
- 微信小程序学习之路 在html中绑定点击事件
- 微信小程序开发小白学习之路--事件
- 微信小程序学习之路01-初识微信小程序
- 微信小程序学习之路(二) ------ 组件
- 微信小程序之目前为止史上最全的微信小程序项目实例, 微信小程序实战学习
- 微信小程序开发视频教程学习(第6天)2017年6月29日:上午前端下午PHP
- EA&UML日拱一卒-0基础学习微信小程序(13)-一个都不能少
- SpringBoot学习之路:02.第一个程序Hello World及项目结构介绍
- 微信小程序学习用精品demo:跟单
- 微信小程序入门资料,学习资料汇总
- 微信小程序学习一初探“小程序”
- 微信小程序开发 -- 学习笔记
- C++ 学习之路(8):C++程序的多文件组成
- IOS学习之路二十(程序json转换数据的中文字符问题解决)
- 微信小程序学习(一)
- 微信小程序开发之扫码 扫一扫 wx.scanCode()
- 微信小程序学习(1)_微信小程序简介