new Vue({ el: '#app', data() { return { data: [], childrenVisible: false } }, mounted: function () { axios.get('data/example-data.json') .then(response => { this.data = response.data.map(item => { item.childrenVisible = false; item.children.has_nemesis.records = item.children.has_nemesis.records.map(child => { child.childrenVisible = true; return child; }); return item; }); console.log(response); }) .catch(error => { console.log(error); }); }, methods: { toggleChildren(item) { item.childrenVisible = !item.childrenVisible; }, removeItem(item,parent) { if (parent) { const index = parent.children.has_nemesis.records.indexOf(item); parent.children.has_nemesis.records.splice(index, 1); } else { const index = this.data.indexOf(item); this.data.splice(index, 1); } }, } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)