Skip to content

SearchBox-DEMO


标准

禁用

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

<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" v-model:resultPlaceholder="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;">
                <div style="position: relative; width: 100%; height: 40px; display: flex; align-items: center;">
                    <fv-img v-for="(item, index) in x.data.people" :key="index" :src="item" style="width: 25px; height: 25px; margin: 5px; border-radius: 50%;" @click.capture="resultPlaceholder.push(item)"/>
                </div>
                <span>
                    <p v-for="(item, index) in x.data.pos" class="list-item" :key="index">{{item}}</p>
                </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
<fv-SearchBox icon="Search" placeholder="Search" :options="items" underline></fv-SearchBox>

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

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

SearchBox-Dark Theme


  1. 原始模板
  1. 自定义模板
vue
<div style="width: 100%; padding: 25px; background: black;">
    <fv-SearchBox icon="Search" placeholder="Search" theme="dark" :options="items"></fv-SearchBox>
</div>
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" v-model:resultPlaceholder="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;">
                <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.capture="resultPlaceholder.push(item)"/>
                </div>
                <span>
                    <p v-for="(item, index) in x.data.pos" class="list-item" :key="index">{{item}}</p>
                </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


自定义边框颜色

自定义背景

vue
<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>

<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>

属性


PropertyTypeRequiredDefaultDescription
modelValuestringNo''组件的 v-model 值。
optionsarrayNo[]搜索结果选项。
placeholderstringNo''输入框占位文本。
typestringNo'text'输入框类型。
readonlybooleanNofalse是否只读。
maxlengthstringNo''最大输入长度。
customFilterbooleanNofalse是否使用自定义过滤逻辑。
resultPlaceholderbooleanNofalse结果占位内容。
focusShowbooleanNofalse获取焦点时是否显示结果。
leftIconstringNo''左侧图标。
iconstringNo''右侧图标。
underlinebooleanNofalse是否使用下划线样式。
backgroundstringNo''搜索框背景。
hoverBackgroundstringNo''搜索框 hover 背景。
borderWidthnumberNo1边框宽度。
borderColorstringNo''边框颜色。
focusBorderColorstringNo''聚焦时边框颜色。
foregroundstringNo''文本颜色。
fontSizenumberNo13.3字体大小。
fontWeightstringNo'normal'字体粗细。
textAlignstringNo'left'文本对齐方式。
borderRadiusnumberNo3搜索框圆角。
resultBackgroundstringNo''搜索结果容器背景。
resultBorderRadiusstringNo''搜索结果容器圆角。
resultBoxShadowbooleanNofalse是否显示 $ms-depth-shadow-16
revealBorderbooleanNofalse是否启用 reveal 边框效果。
statusstringNo''状态样式。
debounceDelaynumberNo300防抖延迟。
disabledbooleanNofalse是否禁用。
themestringNo'global'主题。
isBoxShadowbooleanNofalse搜索框本体是否显示阴影。
langstringNo"global"语言。

事件


EventArgumentsDescription
keydownevent键盘按下事件。
keyupevent键盘抬起事件。
changeevent输入值变更事件。
pasteevent粘贴事件。
left-icon-clickevent左侧图标点击事件。
icon-clickevent右侧图标点击事件。
lazyloadarray搜索结果滚动到底部时触发。
update:resultPlaceholderarray更新结果占位内容。
clear-clickarray清空按钮点击事件。
choose-resultobject选择搜索结果后触发。
debounce-inputstring防抖后的输入内容。

插槽


  1. SearchResult

用于自定义搜索结果区域,插槽参数包含:

  • data: 当前过滤后的结果数据
  • chooseResult: 选择结果时调用的方法
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

用于自定义左侧结果占位区域。

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

Data


  1. options
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