Skip to content

SearchBox-DEMO


Standard

Disabled

vue
Standard
<fv-SearchBox icon="Search" placeholder="Search" :options="items"></fv-SearchBox>

Disabled
<fv-SearchBox icon="Search" placeholder="Search" :options="items" disabled></fv-SearchBox>

SearchBox-RevealBorder

vue
<fv-SearchBox placeholder="Please enter the text here." icon="Search" :options="items" :revealBorder="true" borderColor="rgba(0, 0, 0, 0.01)" borderRadius="3" :isBoxShadow="true"></fv-SearchBox>

SearchBox-Custom Search Result


vue
<div>
    <fv-SearchBox v-model="value" icon="Search" placeholder="Search" :options="custom_items" :focusShow="true" :customFilter="customFilterFunc" :resultPlaceholder.sync="resultPlaceholder">
        <template v-slot:resultPlaceholder="x">
            <fv-img v-for="(item, index) in resultPlaceholder" :key="index" :src="item" style="width: 25px; height: 25px; margin: 0px 3px; border-radius: 50%;"/>
        </template>
        <template v-slot:searchResult="x">
            <div style="position: relative; width: 100%; height: auto; display: flex; flex-direction: column;">
                <span class="list-item list-title">人物</span>
                <div style="position: relative; width: 100%; height: 60px; display: flex;">
                    <fv-img v-for="(item, index) in x.data.people" :key="index" :src="item" style="width: 50px; height: 50px; margin: 5px; border-radius: 50%;" @click.native="resultPlaceholder.push(item)"/>
                </div>
                <span class="list-item list-title">位置</span>
                <span>
                    <p v-for="(item, index) in x.data.pos" class="list-item" :key="index">{{item}}</p>
                </span>
                <span class="list-item list-title">职业</span>
                <span>
                    <p v-for="(item, index) in x.data.pro" class="list-item" :key="index">{{item}}</p>
                </span>
            </div>
        </template>
    </fv-SearchBox>
</div>

TextBox-With Underline And Borderless


  1. Light
  1. Dark
  1. Underline with Reveal
vue
1. Light

<fv-SearchBox icon="Search" placeholder="Search" :options="items" underline></fv-SearchBox>

2. Dark

<fv-SearchBox icon="Search" placeholder="Search" theme="dark" :options="items" underline></fv-SearchBox>

3. Underline with Reveal

<fv-SearchBox icon="Search" placeholder="Search" :options="items" :revealBorder="true" underline></fv-SearchBox>

SearchBox-Dark Theme


  1. Original Template
  1. Custom Template
vue
1. Original Template

<div style="width: 100%; padding: 25px; background: black;">
    <fv-SearchBox icon="Search" placeholder="Search" theme="dark" :options="items"></fv-SearchBox>
</div>
  1. Custom Template
vue
<div style="width: 100%; padding: 25px; background: black;">
    <fv-SearchBox v-model="value" icon="Search" placeholder="Search" theme="dark" :options="custom_items" :focusShow="true" :customFilter="customFilterFunc" :resultPlaceholder.sync="resultPlaceholder">
        <template v-slot:resultPlaceholder="x">
            <fv-img v-for="(item, index) in resultPlaceholder" :key="index" :src="item" style="width: 25px; height: 25px; margin: 0px 3px; border-radius: 50%;"/>
        </template>
        <template v-slot:searchResult="x">
            <div style="position: relative; width: 100%; height: auto; display: flex; flex-direction: column;">
                <span class="list-item list-title">人物</span>
                <div style="position: relative; width: 100%; height: 60px; display: flex;">
                    <fv-img v-for="(item, index) in x.data.people" :key="index" :src="item" style="width: 50px; height: 50px; margin: 5px; border-radius: 50%;" @click.native="resultPlaceholder.push(item)"/>
                </div>
                <span class="list-item list-title">位置</span>
                <span>
                    <p v-for="(item, index) in x.data.pos" class="list-item" :key="index">{{item}}</p>
                </span>
                <span class="list-item list-title">职业</span>
                <span>
                    <p v-for="(item, index) in x.data.pro" class="list-item" :key="index">{{item}}</p>
                </span>
            </div>
        </template>
    </fv-SearchBox>
</div>

TextBox-Customize


Customize border color

Customize background

vue
Customize border color
<div style="width: 100%; padding: 25px; background: black;">
    <fv-SearchBox icon="Search" placeholder="Search" theme="dark" :options="items" borderColor="rgba(0,153,204,1)" focusBorderColor="rgba(0,204,153,1)"></fv-SearchBox>
</div>

Customize background
<div style="width: 100%; padding: 25px; background: black;">
    <fv-SearchBox icon="Search" placeholder="Search" theme="dark" :options="items" background="rgba(0,153,204,1)" borderColor="rgba(0,153,204,1)"></fv-SearchBox>
</div>

Propoties


属性(attr)类型(type)必填(required)默认值(default)说明(statement)
valueStringNoUsing v-model binding input value
options[array or object]YesN/ASearchBox搜索候选数据
placeholderStringNoN/A等同HTML[input]
typeStringNotext等同HTML[input]
readonlyBooleanNofalse等同HTML[input]
maxlengthNumberNoN/A等同HTML[input]
customFilter[object(function)]NoN/A客制化搜索筛选函数
resultPlaceholderArrayNoN/A结果占位数据, 显示在SearchBox左端
focusShowBooleanNofalse是否开启获取焦点时显示结果框
leftIconStringNoN/A左图标
iconStringNoN/A右图标
underlineBooleanNofalse是否开启Underline风格的SearchBox
background[string(color)]NoN/A背景色
borderWidthBooleanNo1
borderColor[string(color)]NoN/A
focusBorderColor[string(color)]NoN/A
fontSizeNumberNo13.3
fontWeight[string,number]Nonormal
foreground[string(color)]NoN/A
textAlignStringNoleft
borderRadiusNumberNoN/ATextbox圆角大小, 启用revealBorder时将失效
revealBorderBooleanNofalse
status['warn','correct']NoN/A状态边框预设, 默认有警告和正确两种
debounceDelayNumberNo300搜索节流延迟时间
disabledBooleanNofalse
themeStringNosystem主题样式, 包含light, dark, system, custom几种样式

Events


事件名(Name)参数类型(args)说明(statement)
keydownevent
keyupevent
changeevent
pasteevent
left-icon-clickevent
icon-clickevent
lazyloadarray搜索结果框滚动加载事件, 滑动到最底部时触发, 返回当前搜索筛选数据
update:resultPlaceholderarray更新搜索占位数组, 在清除搜索框时触发清除搜索占位数组, 再按下退格键时若文本为空, 清除最后一个搜索占位数据项
clear-clickarray清除搜索框文本时触发
choose-resultobject搜索结果框选中项目后返回当前项
debounce-inputstring搜索节流内容反馈

Slot


  1. SearchResult

默认情况下用户可直接在options中定义name来应用默认样式, 不需要修改此模板, 可缺省 用户自定义样式时, 包含以下可选属性

  • data: 传入的filterOptions
  • chooseResult: 用于回调的选择出发函数, 需要传入一个对象, 包含itemitem.name属性
vue
 <template v-slot:searchResult="x">
    <fv-list-view v-model="x.data" :theme="theme" style="width: 100%; height: auto;" @chooseItem="x.chooseResult"></fv-list-view>
</template>
  1. ResultPlaceholder

用户根据自己的需要在搜索框选择结果后将值显示在SearchBox左侧显示相应数据, 数据模板即为ResultPlaceholder

vue
<template v-slot:resultPlaceholder="x">
    <div></div>
</template>

Data


  1. options

数据格式参考ListViewitems的形式, 其中key字段建议开发者在有重复名称和类型字段时声明用来区别项目

javascript
options = [{key: '', name: '', type: '', disabled: ''}]

//e.g.//

options: [
    { key: "fruitsHeader", name: "Fruits", type: "header" },
    { key: "apple", name: "Apple" },
    { key: "banana", name: "Banana" },
    { key: "orange", name: "Orange", disabled: true },
    { key: "grape", name: "Grape" },
    { key: "divider_1", name: "", type: "divider" },
    { key: "vegetablesHeader", name: "Vegetables", type: "header" },
    { key: "broccoli", name: "Broccoli" },
    { key: "carrot", name: "Carrot" },
    { key: "lettuce", name: "Lettuce" }
]

MIT Licensed