vue-select v-model 减少不起作用/Nuxt js Vue js

问题描述 投票:0回答:2

我正在使用 vue-select。 当我想显示所选元素时,它会显示值而不是文本(请参见屏幕)。 我在几份报告(以及文档)中看到我可以使用reduce。 我还看到我可以在组件上添加“:key”道具,但这也不起作用。

我在这里选择项目:

enter image description here

这里选择的项目,它显示值而不是文本:(这里是问题)

enter image description here

我的组件文件(input-custom.vue):

enter image description here

我的页面组件: enter image description here

页面数据:

enter image description here

vue.js nuxt.js vue-select
2个回答
0
投票

我找到了解决方案。

这是我的“handleInput”方法。

我发出“e.value”,但我想发出对象,所以替换“e.value”=>“e”


0
投票
here there are three props used:

 - :options="optionsVariable" - optionsVariable contains array of objects/Array
 - label="optionName"- label prop is the Array Item which You need to display ( here from each array of objects, you display 'optionName'.
 - :reduce="option => option.optionValue" - reduce will store optionValue from each array of objects to the v-model variable 'vModelVariable'

<v-select
 label="optionName" 
 :options="optionsVariable" 
 v-model="vModelVariable" 
 :reduce="option => option.optionValue"
 :placeholder="Enter Placeholder"
>
</v-select>
© www.soinside.com 2019 - 2024. All rights reserved.