console
Skip to content
Features Explore Pricing
This repository
Search
Sign in or Sign up
Watch 2,708 Star 46,960 Fork 6,078 vuejs/vue
Code Issues 55 Pull requests 14 Projects 1 Wiki Pulse Graphs
Branch: dev Find file Copy pathvue/examples/tree/tree.js
ceab86d on 16 Apr 2016
@yyx990803 yyx990803 add e2e tests
1 contributor
RawBlameHistory
76 lines (73 sloc) 1.27 KB
var data = {
name: 'My Tree',
children: [
{ name: 'hello' },
{ name: 'wat' },
{
name: 'child folder',
children: [
{
name: 'child folder',
children: [
{ name: 'hello' },
{ name: 'wat' }
]
},
{ name: 'hello' },
{ name: 'wat' },
{
name: 'child folder',
children: [
{ name: 'hello' },
{ name: 'wat' }
]
}
]
}
]
}
Vue.component('item', {
template: '#item-template',
props: {
model: Object
},
data: function () {
return {
open: false
}
},
computed: {
isFolder: function () {
return this.model.children &&
this.model.children.length
}
},
methods: {
toggle: function () {
if (this.isFolder) {
this.open = !this.open
}
},
changeType: function () {
if (!this.isFolder) {
Vue.set(this.model, 'children', [])
this.addChild()
this.open = true
}
},
addChild: function () {
this.model.children.push({
name: 'new stuff'
})
}
}
})
var demo = new Vue({
el: '#demo',
data: {
treeData: data
}
})
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<launch-tree :list='list' :options='options'></launch-tree>