Skip to content

Commit cda1fe7

Browse files
author
Shaun Pelling
committed
lesson 12 code
1 parent 64a1d6a commit cda1fe7

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
new Vue({
22
el: '#vue-app',
33
data: {
4-
error: false,
5-
success: false
4+
characters: ['Mario', 'Luigi', 'Yoshi', 'Bowser'],
5+
ninjas: [
6+
{ name: 'Ryu', age: 25 },
7+
{ name: 'Yoshi', age: 35 },
8+
{ name: 'Ken', age: 55 }
9+
]
610
},
711
methods: {
812

index.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
</head>
99
<body>
1010
<div id="vue-app">
11-
<h1>Conditionals</h1>
12-
<button v-on:click="error = !error">Toggle error</button>
13-
<button v-on:click="success = !success">Toggle success</button>
14-
<!-- <p v-if="error" class="error">There has been an error</p>
15-
<p v-if="success" class="success">Whooo, success :)</p> -->
16-
<p v-show="error" class="error">There has been an error</p>
17-
<p v-show="success" class="success">Whooo, success :)</p>
11+
<h1>Looping through lists</h1>
12+
<ul>
13+
<li v-for="character in characters">{{ character }}</li>
14+
</ul>
15+
<ul>
16+
<li v-for="(ninja, index) in ninjas">{{ index }} . {{ ninja.name }} - {{ ninja.age }}</li>
17+
</ul>
18+
<template v-for="(ninja, index) in ninjas">
19+
<h3>{{ index }} . {{ ninja.name }}</h3>
20+
<p>Age - {{ ninja.age }}</p>
21+
</template>
1822
</div>
1923
</body>
2024

0 commit comments

Comments
 (0)