Skip to content

Commit 17853ff

Browse files
author
Shaun
authored
Merge pull request iamshaunjp#2 from iamshaunjp/lesson-24
Lesson 24
2 parents b44bd09 + 721435a commit 17853ff

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

src/App.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<template>
22
<div>
3-
<app-header></app-header>
4-
<app-ninjas></app-ninjas>
5-
<app-footer></app-footer>
3+
<app-header v-bind:title="title" v-on:changeTitle="updateTitle($event)"></app-header>
4+
<app-ninjas v-bind:ninjas="ninjas"></app-ninjas>
5+
<ul>
6+
<li v-for="ninja in ninjas">{{ ninja.name }}</li>
7+
</ul>
8+
<app-footer v-bind:title="title"></app-footer>
69
</div>
710
</template>
811

@@ -20,8 +23,21 @@ export default {
2023
},
2124
data () {
2225
return {
23-
26+
ninjas: [
27+
{name: 'Ryu', speciality: 'Vue Components', show: false},
28+
{name: 'Crystal', speciality: 'HTML Wizardry', show: false},
29+
{name: 'Hitoshi', speciality: 'Click Events', show: false},
30+
{name: 'Tango', speciality: 'Conditionals', show: false},
31+
{name: 'Kami', speciality: 'Webpack', show: false},
32+
{name: 'Yoshi', speciality: 'Data Diggin', show: false}
33+
],
34+
title: 'Vue Wizards'
2435
}
36+
},
37+
methods: {
38+
updateTitle: function(updatedTitle){
39+
this.title = updatedTitle;
40+
}
2541
}
2642
}
2743
</script>

src/components/Footer.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<template>
22
<footer>
3-
<p>{{ copyright }}</p>
3+
<p>Copyright 2017 {{ title }}</p>
44
</footer>
55
</template>
66
<script>
77
export default {
8+
props: {
9+
title: {
10+
type: String,
11+
required: true
12+
}
13+
},
814
data(){
915
return{
10-
copyright: 'Copyright 2017 Vue Ninjas'
16+
1117
}
1218
}
1319
}

src/components/Header.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
<template>
22
<header>
3-
<h1>{{ title }}</h1>
3+
<h1 v-on:click="changeTitle">{{ title }}</h1>
44
</header>
55
</template>
66
<script>
77
export default {
8+
props: {
9+
title: {
10+
type: String,
11+
required: true
12+
}
13+
},
814
data(){
915
return{
10-
title: 'Vue Ninjas'
16+
1117
}
18+
},
19+
methods: {
20+
changeTitle: function(){
21+
this.$emit('changeTitle', 'Vue Ninjas');
22+
}
1223
}
1324
}
1425
</script>

src/components/Ninjas.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66
<h3 v-show="ninja.show">{{ ninja.speciality }}</h3>
77
</li>
88
</ul>
9+
<button v-on:click="deleteNinja">Delete a Ninja</button>
910
</div>
1011
</template>
1112
<script>
1213
export default {
14+
props: {
15+
ninjas: {
16+
type: Array,
17+
required: true
18+
}
19+
},
1320
data(){
1421
return{
15-
ninjas: [
16-
{name: 'Ryu', speciality: 'Vue Components', show: false},
17-
{name: 'Crystal', speciality: 'HTML Wizardry', show: false},
18-
{name: 'Hitoshi', speciality: 'Click Events', show: false},
19-
{name: 'Tango', speciality: 'Conditionals', show: false},
20-
{name: 'Kami', speciality: 'Webpack', show: false},
21-
{name: 'Yoshi', speciality: 'Data Diggin', show: false}
22-
]
22+
2323
}
24+
},
25+
methods: {
26+
deleteNinja: function(){
27+
this.ninjas.pop();
28+
}
2429
}
2530
}
2631
</script>

0 commit comments

Comments
 (0)