gpt4 book ai didi

vue.js - Vuetify Combobox 多选对象

转载 作者:行者123 更新时间:2023-12-03 06:42:06 37 4
gpt4 key购买 nike

我的数据源是:

[
{
"display": "client",
"value": "client"
},
{
"display": "firstname",
"value": "firstname"
},
{
"display": "lastname",
"value": "lastname"
}
]
我需要保持这种格式。
在我的应用程序中,我需要添加键(如添加标签)的可能性,我使用组合框,我可以显示数据。
但是当添加一个新元素时,它不保留对象格式。
这是我的代码:
  <v-combobox
v-model="password.keys"
label="Add keys"
chips
item-text="display"
item-value="value"

prepend-icon="filter_list"
solo
multiple
>
<template slot="selection" slot-scope="data">
<v-chip
:selected="data.selected"
close
@input="remove(data.item)"
>
<strong>{{ data.item.display }}</strong>&nbsp;
</v-chip>
</template>
</v-combobox>
纯文本
show the text only
完整对象显示
full object display
如何在保持对象格式的同时添加新对象?

最佳答案


<v-combobox :return-object="false">
<template slot="selection" slot-scope="data">
<v-chip
:selected="data.selected"
close
@input="remove(data.item)"
>
<strong>{{ getItemText(data.item) }}</strong>&nbsp;
</v-chip>
</template>
</v-combobox>


methods: {
getItemText(val) {
const item = this.tags.find((i) => i.value === val);
return item ? item.text : "";
}
}

关于vue.js - Vuetify Combobox 多选对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54879154/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com