gpt4 book ai didi

vue.js - 具有深层嵌套数据的 Vue 选择

转载 作者:行者123 更新时间:2023-12-02 16:48:13 25 4
gpt4 key购买 nike

我正在尝试根据官方文档中的说明进行 v-select,但我的数据比文档中显示的数据嵌套更多,我无法在我的 v-select 中显示 llcName我的数据,我坚持这个。

这是我的 html div 和 Vue 实例,下面有数据

<div id="vs">
<h1>Vue Select</h1>
<v-select multiple :options="options" :reduce="node=> node.llcName" label='llcName' v-model='selected' />
<pre>[[$data]]</pre>
</div>

<script>


Vue.component('v-select', VueSelect.VueSelect)

new Vue({
el: '#vs',
delimiters: ["[[", "]]"],
data: {
options: [
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA1",
"llcName": "new",
"suppPayment": {
"edges": [0]
}
}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA2",
"llcName": "new2",
"suppPayment": {
"edges": [1]
}

}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA3",
"llcName": "rteer",
"suppPayment": {
"edges": [2]
}
}
}
],
selected:"",
}
})
</script>

最佳答案

我认为你应该使用 getOptionLabel而不是 label 并且您的 reduce 属性中存在错误。

<v-select
multiple
v-model='selected'
:options='options'
:get-option-label='option => option.node.llcName'
:reduce='option => option.node.llcName'/>

Fiddle

关于vue.js - 具有深层嵌套数据的 Vue 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59694198/

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