E企盈营销工具技术服务商 热线:4006-838-530

微信小程序的开发之搜索功能

E企盈直播平台营销卖货系统

就直接贴代码啦~wxmlview class=”weui-search-bar”   view class=”weui-search-bar__form”    view class=”weui-search-bar__box”      icon class=”weui-icon-search_in-box” type=”search” size=”14″/icon      input type=”text” class=”weui-search-bar__input” placeholder=”请输入搜索内容” value=”{{wxSearchData}}” bindinput=”wxSearchInput” bindconfirm=”wxSearchConfirm” /      view class=”weui-icon-clear” wx:if=”{{wxSearchData.value.length 0}}” bindtap=”wxSearchClear”        icon type=”clear” size=”14″/icon      /view    /view  /view    view class=”weui-search-bar__cancel-btn” bindtap=”back”         text data-key=’back’返回/text     /view/viewjs/**   * 页面的初始数据   */  data: {    lists: [],              // 接收搜索的内容    wxSearchData: ”,       // 输入的值  },/**   * 搜索   */  wxSearchInput: function (value) {    var that = this;    if (value.detail.value.length 0) {      wx.request({        url: ”,        data: {          value: value.detail.value        },        header: { ‘content-type’: ‘application/x-www-form-urlencoded’ },        method: ‘POST’,        dataType: json,        responseType: text,        success: function (res) {          if (res.code) {            var data = that.data.lists;            for (let i = 0; i res.data.length; i++) {                data.push(res.data[i]);            }            that.setData({              wxSearchData: value.detail.value,              lists: data            })          }        },        fail: function (res) { },        complete: function (res) { },      })    }  },  /**   * 监听软键盘确认键   */  wxSearchConfirm: function (e) {  },  /**   * 返回   */  back: function (e) {    wx:wx.navigateBack({      delta: 1,    })  }

赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 微信小程序的开发之搜索功能
分享到: 更多 (0)
E企盈小程序直播营销卖货系统
E企盈直播平台营销卖货系统

评论 抢沙发

E企盈小程序开发

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏