在VUE中,使用SELECT在一个对象数组中选择对象
我有一个带有选项的元素,该元素通过一系列对象( services )循环。
<select placeholder="Vælg ydelse">
<option v-for="service in services" :key="service.id">
{{service.name}}
</option>
</select>
在我的数据对象中,我
chosenService: {
id: 42,
name: "some service",
group: {
id: 2,
name: "some group within the service",
},
additions: [],
classSignupMoreActive: false,
},
想在选择选择后要检索。
最后,我正在从父母那里发送服务数组,因为所有这些都在组件中发生。我不确定这是否是最正确的方法。
像这样:
<Modal
:show="showModal"
@close="showModal = false"
title="Modal Title"
:services="this.services"
>
</Modal>
I have a select element with options, which loops through an array of objects (services).
<select placeholder="Vælg ydelse">
<option v-for="service in services" :key="service.id">
{{service.name}}
</option>
</select>
In my data object, I have
chosenService: {
id: 42,
name: "some service",
group: {
id: 2,
name: "some group within the service",
},
additions: [],
classSignupMoreActive: false,
},
Which I'd like to be retrieved once the select is changed.
Finally, I'm sending the services array from the parent, as all of this is happening in a component. I'm not sure if this is the most correct way to do it.
Like this:
<Modal
:show="showModal"
@close="showModal = false"
title="Modal Title"
:services="this.services"
>
</Modal>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
V-Model
并将对象传递给:value
选项的属性:You can use
v-model
and pass object to:value
property of option: