微信小程序 WeUI搜索组件


本文整理自网络,侵删。

Searchbar

搜索组件Searchbar提供搜索的功能,并展示搜索的结果。

示例代码:

{
  "usingComponents": {
    "mp-searchbar": "../components/searchbar/searchbar"
  },
  "navigationBarTitleText": "UI组件库"
}
<view class="page">
    <view class="page__hd">
        <view class="page__title">SearchBar</view>
        <view class="page__desc">搜索栏</view>
    </view>
    <view class="page__bd">
        <mp-searchbar bindselectresult="selectResult" search="{{search}}"></mp-searchbar>
    </view>
</view>
Page({
    data: {
        inputShowed: false,
        inputVal: ""
    },
    onLoad() {
        this.setData({
            search: this.search.bind(this)
        })
    },
    search: function (value) {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve([{text: '搜索结果', value: 1}, {text: '搜索结果2', value: 2}])
            }, 200)
        })
    },
    selectResult: function (e) {
        console.log('select result', e.detail)
    },
});


属性列表

属性类型默认值必填说明
ext-classstring添加在组件内部结构的class,可用于修改组件内部的样式
focusbooleanfalse是否在组件开始创建的时候focus搜索输入框
placeholderstring搜索搜索输入框的placeholder
valuestring搜索输入框的默认值
searchfunction输入过程不断调用此函数得到新的搜索结果,参数是输入框的值value,返回Promise实例
throttlenumber500调用search函数的间隔,单位ms
cancelTextstring取消取消按钮的文本
cancelbooleantrue是否显示取消按钮
bindfocuseventhandle在输入框focus的时候触发事件
bindblureventhandle在输入框blur的时候触发事件
bindcleareventhandle在clear按钮点击的时候触发事件
bindinputeventhandle在输入框输入过程中触发事件
bindselectresulteventhandle在选择搜索结果的时候触发事件



标签:微信小程序

相关阅读 >>

sdk数据库 command更新数组操作符

微信小程序云开发服务端数据库api 创建集合

微信小程序 插件功能页

微信小程序 小程序使用onpathupdate

微信小程序api 图片-获取图片信息

微信小程序 快递接口(商家查看)-联系我们

微信小程序 扩展组件小程序弹幕组件

微信小程序 工具库类lottie

微信小程序api 绘图setfontsize(设置字号)

微信小程序api 数据自定义数据上报

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...