使用BootstrapVue选择Vue表单

时间:2019-04-15 06:38:11

标签: forms vue.js vuejs2 bootstrap-vue

我打开了BootrapVue表单选择(https://bootstrap-vue.js.org/docs/components/form-select),当我在字段中键入内容时,我希望'value'(BEL)进入结果(而不是过滤掉):

https://jsfiddle.net/a942w6x3/2/

我想输入“ BEL”并选择(或激活)贝尔法斯特。

在保留完整列表的同时,结合了预先输入的功能。

<b-form-select v-model="selected" :name="name">
    <option v-for="(option, index) in filteredNames" :value="option.value">{{ option.text }}</option>
</b-form-select>

js:

   data() {
    return {
      selected: 'BEL',
      options: [
        {"text":"Aberdeen","value":"ABZ"},
        {"text":"Belfast","value":"BEL"},
        {"text":"Bradford","value":"BRF"},
        {"text":"Essex","value":"ESS"},
        {"text":"London","value":"LDN"}
      ]
    }

我正在尝试使用计算机来实现这一目标:

  computed: {
    filteredNames() {
      let filter = new RegExp(this.findName, 'i')
      return this.options.filter(el => el.text.match(filter) || el.value.match(filter))
    }
  }

有没有人看到这完成了,或者让我指出了我所开始的方向,我不想使用任何其他第三方代码。

0 个答案:

没有答案
相关问题