单击 v-select 项时如何获取对象而不是单个值? [英] How to get an object rather than a single value when clicking on a v-select item?
本文介绍了单击 v-select 项时如何获取对象而不是单个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的v-select
的数据是一个对象数组.对于每个项目,value
是一个属性,而该项目的 text
是一个不同的属性.但是我真的需要检索两者,而不仅仅是 value
.
My v-select
's data is an array of objects. For each item, the value
is one property and the text
for that item is a different property. However I really need to retrieve both, not just the value
.
所以我想我需要检索对象.可能吗?
So I guess I need to retrieve the object. Is it possible?
V-选择代码:
<v-select
:items="projects"
v-model="project"
item-text="projectName"
item-value="projectId"
solo
></v-select>
这是填充项目数组的方式(在安装的钩子中):
querySnapshot.forEach((doc) => {
let data = {
'projectId': doc.id,
'projectName': doc.data().name,
'clientId': doc.data().clientId
}
this.projects.push(data);
});
推荐答案
添加 return-object
道具:
<v-select return-object>
查看文档:
https://vuetifyjs.com/en/components/选择#example-custom-text-and-value
这篇关于单击 v-select 项时如何获取对象而不是单个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文