Ant—Design下拉選擇器自帶搜索功能


<a-form-model-item label="贈品:" style="margin-top:20px">
  <a-select placeholder='請選擇贈品' :filterOption="filterOption" show-search @change="filterGift">
    <a-select-option v-for="(item,index) in giveawayList" :key="index" :value="item.id">
      {{item.name}}
    </a-select-option>
  </a-select>
</a-form-model-item>
filterOption (input, option) {
  return (
    option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  )
}

主要是 filterOption 和 show-search 來實現搜索,如下圖所示:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM