小程序:动态监测input和取值

1.输入框失去焦点取值

  wxml:

    <input bindblur="tab" type='text'></input>
  js:
  tab:function(e){
    console.log(e)
  }
 
2.动态监测input输入的值
   wxml:
    <input type='number' bindinput='change' placeholder="请输入" placeholder-class="placeholder" focus="true"></input>
    focus 进入这个搜索页面后自动获取焦点
  js:
  change: function(r) {
    console.log(r.detail.value)
    this.setData({
      key: r.detail.value
    })
  },

猜你喜欢

转载自www.cnblogs.com/naturl/p/10523378.html