append item in treeview vuetify
addChild(item) {
if (!item.children) {
this.$set(item, "children", []);
}
const name = `${item.name} (${item.children.length})`;
const id = this.nextId++;
item.children.push({
id,
name
});
}
append item in treeview vuetify
addChild(item) {
if (!item.children) {
this.$set(item, "children", []);
}
const name = `${item.name} (${item.children.length})`;
const id = this.nextId++;
item.children.push({
id,
name
});
}
append item in treeview vuetify
<v-app>
<v-treeview :items="items">
<template slot="append" slot-scope="{ item }">
<v-btn @click="addChild(item);">Add child</v-btn>
</template>
</v-treeview>
</v-app>
append item in treeview vuetify
findItem(id, items = null) {
if (!items) {
items = this.items;
}
return items.reduce((acc, item) => {
if (acc) {
return acc;
}
if (item.id === id) {
return item;
}
if (item.children) {
return this.findItem(id, item.children);
}
return acc;
}, null);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us