【问题标题】:vuetify combobox getting search string value as input on blurvuetify 组合框获取搜索字符串值作为模糊输入
【发布时间】:2019-02-28 15:35:59
【问题描述】:

我有一个简单的 v-combobox,我可以在其中从对象列表中选择/取消选择多个项目。

<div id="app">
  <v-app>
    <v-layout column>
      <v-form v-model="valid">
        <v-combobox
          v-model="selectedItems"
          item-text="name"
          item-value="id"
          :items="itemsList"
          label="Items"
          multiple
          clerable
          persistent-hint
          chips>
          </v-combobox>
        <div>{{selectedItems}}</div>
        </v-form>
     </v-layout>
  </v-app>
</div>

https://codepen.io/anon/pen/pYjZaN 问题是当我在该字段中编写一个搜索字符串然后单击外部时,我得到一个芯片而不是什么都不做。 看起来它依赖于 v-form,删除它一切都会正常工作。 有谁知道如何处理这个问题?

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    原因是您使用的是v-combobox。来自their website:“使用组合框,您可以允许用户创建可能不存在于提供的项目列表中的新值。”尝试v-autocomplete,现在如果您尝试搜索项目列表中不存在的字符串,您将得到“数据不可用”

    【讨论】:

      【解决方案2】:

      您可以自己处理模糊事件。这将删除默认的 v-chip 创建行为。为此,您需要执行 &lt;v-combobox @blur="blurHandler()" 并将 blurHandler() { // Do something or nothing here } 之类的内容添加到脚本中。

      【讨论】:

        猜你喜欢
        • 2017-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-13
        • 2020-07-02
        • 1970-01-01
        • 2015-01-28
        • 2020-01-26
        相关资源
        最近更新 更多