【发布时间】: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