AutoComplete 是一個(gè)輸入框自動(dòng)完成功能,在輸入時(shí)提個(gè)建議或者輔助提示。
和 Select 的區(qū)別是:
- AutoComplete 是一個(gè)帶提示的文本輸入框,用戶可以自由輸入,關(guān)鍵詞是輔助輸入
- Select 是在限定的可選項(xiàng)中進(jìn)行選擇,關(guān)鍵詞是選擇。
使用案例如下:文章來源:http://www.zghlxwxcb.cn/news/detail-652003.html
<a-auto-complete
v-model.trim="form.payBankAccountNo"
class="w-full"
placeholder="付款銀行賬戶"
allow-clear
:filter-option="filterOption"
@select="handleSelect"
>
<template slot="dataSource">
<a-select-option
v-for="item in optionsSource"
:key="item.value"
>
{{ item.name}}
</a-select-option>
</template>
</a-auto-complete>
filterOption 是否根據(jù)輸入項(xiàng)進(jìn)行篩選。當(dāng)其為一個(gè)函數(shù)時(shí),會(huì)接收 inputValue option 兩個(gè)參數(shù),當(dāng) option 符合篩選條件時(shí),應(yīng)返回 true,反之則返回 false。文章來源地址http://www.zghlxwxcb.cn/news/detail-652003.html
filterOption (input, option) {
return (
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
)
},
到了這里,關(guān)于Ant-design-vue AutoComplete 自動(dòng)補(bǔ)全組件的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!