微信小程序之监听 input 的 输入值

Posted on 2019-09-23 12:07  jessie-xian  阅读(5316)  评论(0编辑  收藏  举报

wxml

<view class='search_input'>
   <input value='{{search}}' placeholder='请输入姓名' bindblur='changeSearch' bindconfirm='changeSearch' bindinput='changeSearch'></input>
</view>

js


/**
   * 页面的初始数据
   */
  data: {
    search: ''
  }

/**
   * 监听搜索内容
   */
  changeSearch: function(event) {
    let that = this;
    var inputSearch = event.detail.value;
    that.setData({
      search: inputSearch
    })
  }