詳解微信小程序-掃一掃 wx.scanCode() 掃碼大變身
更新時間:2019年04月30日 08:39:00 作者:意外金喜
這篇文章主要介紹了微信小程序-掃一掃wx.scanCode() 掃碼大變身,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
效果
js
let app = getApp(); Page({ data: { img: "/images/1.jpg" }, onLoad() { }, scan() { wx.scanCode({ success: (res) => { console.log("掃碼結(jié)果"); console.log(res); this.setData({ img: res.result }) }, fail: (res) => { console.log(res); } }) } })
html
<view class="view"> <image class="cover-9" src="{{img}}" bindtap="img"></image> <button type="primary" bindtap="scan" id="scan">掃一掃</button> </view>
css
page{ height: 100%; } .view{ width: 100%; height: 100%; } .cover-9{ width: 688rpx; height: 80%; margin: 0 30rpx; border:2rpx solid; border-radius:5px; } button{ margin: 0 10rpx; width: 100%; } #scan{ width: 730rpx; }
其實就是"/images/2.jpg"和"/images/3.jpg"2個字符串生成二維碼,
然后在images文件夾下放對應(yīng)路徑的2張圖片,
掃一掃二維碼重新賦值。
參考地址:
https://mp.weixin.qq.com/debug/wxadoc/dev/api/scancode.html
以上所述是小編給大家介紹的微信小程序-掃一掃wx.scanCode() 掃碼大變身詳解整合,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章: