小程序的事件 bindtap bindinput


一、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
        });
    },

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM