序文
本文为微信小程序开发笔记,现学现卖,正在学习中。
如有发现问题或者发现有什么不足的地方,请大佬们多多指教!!!(开发自己的微信小程序中……)
- 効果を実現する
画像をクリックし、QRコードのスキャンを開始し、スキャンが成功した後にメソッドを呼び出します。 - WXML部分
<view class='form-list'>
<input type='text' value='{
{scanCodeMsg}}'></input>
<image class='scan' bindtap='scanCode' src='/images/scanCode.png' mode='widthFix'></image>
</view>
- JSパート
data: {
scanCodeMsg: "",
},
scanCode: function() {
var that = this;
wx.scanCode({
//扫描API
success(res) {
//扫描成功
console.log(res) //输出回调信息
that.setData({
scanCodeMsg: res.result
});
wx.showToast({
title: '成功',
duration: 1000
})
}
})
},
- コードサンプル(参照学習用)
// 允许从相机和相册扫码
wx.scanCode({
success(res) {
console.log(res)
}
})
// 只允许从相机扫码
wx.scanCode({
onlyFromCamera: true,
success(res) {
console.log(res)
}
})
この記事の参照先:http://caibaojian.com/wx-scancode.html、編集者のおかげです!