【问题标题】:How to do Buefy autocomplete on multiple fields如何在多个字段上进行 Buefy 自动完成
【发布时间】:2020-06-12 14:00:08
【问题描述】:

我正在使用 buefy 自动完成功能开发自动完成功能。它适用于来自对象的单个字段 - {BrandID: 1004487, BrandName: "test"} 目前在 BrandName 上过滤数据

下面是代码 -

<b-autocomplete class="form-control"
  v-model.trim="newMapping.brandname"
  placeholder="Type brand name..."
  :data="filteredBrandData"
  field="BrandName"
  size="is-small"
  :open-on-focus="true"
  @select="option => newMapping.brandid = option.BrandID"
  @typing="clearBrand()">
  <template slot-scope="props">
   <div class="media">
     <div class="media-content">
       {{props.option.BrandName}}
       <br>
       <small>
         BrandId : {{props.option.BrandID}}
       </small>
     </div>
    </div>
   </template>
</b-autocomplete>

Vuejs 函数 -

filteredBrandData () {
  return this.brandList.filter((text) => {
    return text.BrandName.toLowerCase().indexOf(this.newMapping.brandname.toLowerCase()) >= 0
  })
}

我也想过滤/自动完成BrandID 上的数据,我该如何解决这个问题?请提出建议。

Buefy 自动完成 - https://buefy.org/documentation/autocomplete/

【问题讨论】:

    标签: vue.js autocomplete buefy


    【解决方案1】:

    在 b-autocomplete 上尝试这样的操作:@select="option =&gt; mySelectFunction(option)"

    关于脚本:

    private mySelectFunction(option: {code: string; description: string}){
        this.myModel.code = option.code
        this.myModel.description = option.description
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 2019-05-18
      • 1970-01-01
      • 1970-01-01
      • 2013-07-12
      相关资源
      最近更新 更多