Skip to content

Commit

Permalink
add folder component
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed Feb 2, 2017
1 parent 022a9fc commit 9b4bc33
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions index.html
Expand Up @@ -10,15 +10,18 @@
<script type='x-template' id='tree'>
<div>
<div v-for="file in files">
<div v-if="file.tag == 'folder'" v-on:click='toggleExpand()'>
{{file.name}}/
</div>
<folder v-if="file.tag == 'folder'" :file='file'></folder>
<div v-else>
{{file.name}}
</div>
</div>
</div>
</script>
<script type="x-template" id='folder'>
<div v-on:click="toggleExpand()">
{{file.name}}/
</div>
</script>
<script>
let files = [
{tag: 'folder', name: 'dir1'},
Expand All @@ -27,17 +30,21 @@
]
Vue.component('tree',{
template: '#tree',
methods: {
toggleExpand: function(){
console.log('togglin!')
}
},
data(){
return {
files
}
}
})
Vue.component('folder',{
template: '#folder',
props: ['file'],
methods: {
toggleExpand: function(){
console.log('togglin!')
}
}
})
new Vue({
el: '#app'
})
Expand Down

0 comments on commit 9b4bc33

Please sign in to comment.