【问题标题】:Vue: Dropdown box in vue-select not showing value after selectingVue:选择后vue-select中的下拉框不显示值
【发布时间】:2019-08-25 16:55:22
【问题描述】:

我正在从一个返回存储对象数组的计算方法中填充一个下拉列表。然后在 vue-select 中,我将其作为options 传递,并在下拉列表中显示option.address。这按预期工作,但是当单击下拉选项时,该框不显示该值 - 它只是保持空白。

computed: {
   storeLocationsArray: function() {
    let arr = [];
    this.storeLocations.forEach((location,index) => {
        arr.push({id: index, address: location.address})
    })
    return arr;
   }
}

<v-select
    v-model="selectedPickupLocation"
    :options="storeLocationsArray"
>
    <template class="single-option" slot="option" slot-scope="option">
        {{option.address}}
    </template>
</v-select>

【问题讨论】:

  • 你的应用会抛出警告 ~ "[vue-select warn]: 标签键 "option.label" 在选项对象中不存在"。你应该read the documentation

标签: vue.js vuejs2 vue-component vue-select


【解决方案1】:

您可以使用label 来显示address 而不是插槽

<v-select
    v-model="selectedPickupLocation"
    :options="storeLocationsArray"
    label="address"
>
</v-select>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-12
    • 2020-09-21
    • 2023-02-10
    • 2021-02-17
    • 2019-12-24
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多