0

有没有办法使用 av-select来显示数组的值?我需要列出str这个数组的值:

myArr: [
            { key: 'one', str: '1st' },
            { key: 'two', str: '2nd' },
            { key: 'three', str: '3rd' },
            { key: 'four', str: '4th' }
]

在中,v-select但不知道该怎么做。到目前为止,我已经完成了这个工作:

<v-select v-model="vCase.eligibility" :items="eligPeriods[0].str"></v-select>

它在 中显示“1st” v-select。但我需要显示所有值。

我尝试使用模板:

<template v-slot:myArr="{item}">
        <v-select v-model="myVar.selectedVal" :items="item[str]"></v-select>
</template>

但是它甚至不会在页面上呈现。

有什么帮助或建议吗?

4

1 回答 1

0

因为你有一个关联数组作为项目,你需要做这样的事情

<v-select :options="myArr" :reduce="item => item.key" label="item.str" />

你可以在这里阅读更多关于它的信息

于 2020-02-11T11:57:15.793 回答