Skip to content

Commit 488233d

Browse files
author
Shaun Pelling
committed
added lesson 15 code
1 parent 65348d6 commit 488233d

File tree

3 files changed

+12
-61
lines changed

3 files changed

+12
-61
lines changed

app.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
new Vue({
2-
el: '#vue-app',
3-
data: {
4-
health: 100,
5-
ended: false
6-
},
7-
methods: {
8-
punch: function(){
9-
this.health -= 10;
10-
if ( this.health <= 0 ){
11-
this.ended = true;
12-
}
13-
},
14-
restart: function(){
15-
this.health = 100;
16-
this.ended = false;
17-
}
18-
},
19-
computed: {
1+
Vue.component('greeting', {
2+
template: '<p>Hey there, I am a re-usable component</p>'
3+
});
204

21-
}
5+
new Vue({
6+
el: '.vue-app-one'
7+
/*template: '<p>I am a template</p>'*/
228
});

index.html

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@
77
<script src="https://unpkg.com/vue"></script>
88
</head>
99
<body>
10-
<div id="vue-app">
11-
<!-- bag image -->
12-
<div id="bag" v-bind:class="{ burst: ended }"></div>
13-
14-
<!-- bag health bar -->
15-
<div id="bag-health">
16-
<div v-bind:style="{ width: health + '%' }"></div>
17-
</div>
18-
19-
<!-- game control buttons -->
20-
<div id="controls">
21-
<button v-on:click="punch" v-show="!ended">Punch</button>
22-
<button v-on:click="restart">Restart</button>
23-
</div>
10+
<h1>Templates</h1>
11+
<div class="vue-app-one">
12+
<greeting></greeting>
13+
<greeting></greeting>
2414
</div>
15+
<!--<div class="vue-app-one"></div>-->
16+
2517
</body>
2618

2719
<script src="app.js"></script>

styles.css

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +0,0 @@
1-
#bag{
2-
width: 200px;
3-
height: 500px;
4-
margin: 0 auto;
5-
background: url(/img/bag.png) center no-repeat;
6-
background-size: 80%;
7-
}
8-
9-
#bag.burst{
10-
background-image: url(/img/bag-burst.png);
11-
}
12-
13-
#bag-health{
14-
width: 200px;
15-
border: 2px solid #000;
16-
margin: 0 auto 20px auto;
17-
}
18-
19-
#bag-health div{
20-
height: 20px;
21-
background: crimson
22-
}
23-
24-
#controls{
25-
width: 120px;
26-
margin: 0 auto;
27-
}

0 commit comments

Comments
 (0)