How to set the attributes of multiple subitems of v-treeview
P粉852578075
2023-08-28 10:06:59
<p>Suppose I have the variable items with the following structure: </p>
<pre class="brush:php;toolbar:false;">[
{
id: 1,
name: 'value1',
item_nested: [
{
id: 2,
name: 'value2',
},
{
id: 3,
name: 'value3',
nested_item: [
{
id: 4,
name: 'value4'
}
]
}
]
}
]</pre>
<p>In v-treeview we have a props called item-children which accepts a string which allows to set which property will be referenced as a child. In the first level I want to have the attribute <code>item_nested</code> as a child and in the second level I want to have the <code>nested_item</code> as a child but is it possible to set Multiple values for item-children? </p>
VTreeView
uses astring
as the key for the child, so - without extending/overwriting the original component - I don't see a way to provide an alternative key for the child .However, you can always "retype" the objects you want to display in
VTreeview
(this code snippet only applies to this specific case, but can be generalized to other cases):