一、bindtap事件
在wxml文件里綁定:
<view class='wel-list' bindtap='TZdown'> <image src="/images/welcome_08.png"></image> <text>C語言資料下載</text> </view>
在js文件里相應:
Page({ TZdown: function () { wx.navigateTo({ url: '../download/download' }); } })
二、bindinput事件
wxml文件:
<input type="number" placeholder="請輸入手機號" class="inp-holder" maxlength="11" bindinput="getPhone" />
<input type="number" placeholder="請輸入驗證碼" class="inp-holder" maxlength="6" bindinput="getCode" />
js文件:
// 拿到手機號 getPhone: function (e) { var val = e.detail.value; this.setData({ telphone: val }); }, // 拿到驗證碼 getCode: function (e) { var val = e.detail.value; this.setData({ code: val }); },