微信小程序 bind:change bind:blur


bind:blur

失去焦點的時候,會調用這個事件,並且給自定義變量賦值

這樣在點按鈕的時候,最后一個輸入框,總是要提示沒有輸入值。

解決:

bind:change

只要有輸入,有改變就可以更新到變量,這樣就可以解決。

 

<van-field
        value="{{ phone }}"
        label="手機號"
        type="text"
        placeholder="請輸入手機號"
        required="true"
        data-fieldName="phone"
        bind:change="bindPhone"
      />
onChange:function(e) {
 this.setData({ [e.currentTarget.dataset.prop]: e.detail })
},
bindPhone:function(e){
      this.setData({phone:e.detail.value});
  },
注意:
blur事件這個是
e.detail.value

change事件這個是
e.detail
否則獲取到的值是undefined
 
        

 


免責聲明!

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



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