【发布时间】:2023-03-23 16:35:02
【问题描述】:
我是 Vuetify 的新手,在检索 v-select 组件上选定选项的索引时遇到了一些问题。
一旦我有了索引,我想根据点击的选项填充一个文本字段。
我有一组对象,我从 firebase 检索并作为 :items 属性传入。
我可以使用带有 v-for 的标准 select 选项成功获取索引以循环遍历数组,然后使用 @change 调用使用事件对象获取 selectedIndex 的函数。但是,我在尝试使用 v-select 组件时似乎无法弄清楚
这行得通:
<select @change="populateLicense" v-model="trim.shop">
<option value="">Select Shop</option>
<option v-for="item in shopdata" :key="item.id">
{{ item.shopname}}
</option>
</select>
方法:
populateLicense(e) {
let index = e.target.selectedIndex - 1
this.trim.license = this.shopdata[index].license
},
当前的 v-select 组件(不工作):
<v-select
outline
label="Select Shop"
:items="shopdata"
item-text="shopname"
item-value=""
v-model="trim.shop"
@change="populateLicense"
>
</v-select>
我猜item-value 可能会提供我需要的东西,但我不确定我应该分配给它什么
非常感谢任何帮助,谢谢!
【问题讨论】:
标签: javascript vue.js vuetify.js