【问题标题】:Vuetify combobox displaying the id instead of the item-textVuetify 组合框显示 id 而不是 item-text
【发布时间】:2021-10-07 14:15:39
【问题描述】:

我在 Vuetify 中有以下组合框:

<v-combobox v-model="supplier.supplier_type" maxlength="255" :items="company.supplier_types" item-text="name" item-value="id" :label="$t('supplier.supplier_types')" :hide-no-data="true" outlined :error-messages="errors" :return-object="false">
</v-combobox>  

然而,虽然 item-text 在 item slot 中正确显示,但它在 selection slot 中显示了 id:

我是否应该更改组合框上的任何内容?

我尝试使用插槽指定项目文本,但没有成功:

<v-combobox v-model="supplier.supplier_type" maxlength="255" :items="company.supplier_types" item-text="name" item-value="id" :label="$t('supplier.supplier_types')" :hide-no-data="true" outlined :error-messages="errors" :return-object="false">
    <template v-slot:selection="{ item, index }">
        {{item.name}}
    </template>
    <template v-slot:item="{ on, item }">
        <v-list-item v-on="on">
            {{item.name}}
        </v-list-item>
    </template>
</v-combobox>  

【问题讨论】:

    标签: combobox vuetify.js


    【解决方案1】:

    如果return-object 设置为false,则当前有a bugitem-value 相关。

    报告中的引述:“当 v-combobox 上的 return-object 属性设置为 false 时,文本字段 'item-text' 显然会更改为 item-value 的 id。”

    documentation of v-combobox中有提到。

    删除item-value="id" 应该可以修复它,但会导致整个对象成为值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多