Skip to content

Commit 22dbecb

Browse files
author
Shaun Pelling
committed
added lesson 5 code
1 parent 4e009d7 commit 22dbecb

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

app.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
new Vue({
22
el: '#vue-app',
33
data: {
4-
name: 'Shaun',
5-
job: 'Ninja',
6-
website: 'http://www.thenetninja.co.uk'
4+
age: 25,
5+
x: 0,
6+
y: 0
77
},
88
methods: {
9-
greet: function(time){
10-
return 'Good ' + time + ', ' + this.name;
9+
add: function(inc){
10+
this.age += inc;
11+
},
12+
subtract: function(dec){
13+
this.age -= dec;
14+
},
15+
updateXY: function(event){
16+
this.x = event.offsetX;
17+
this.y = event.offsetY;
1118
}
1219
}
1320
});

index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
</head>
99
<body>
1010
<div id="vue-app">
11-
<h1>Data Binding</h1>
12-
<a v-bind:href="website">The Net Ninja Website</a>
13-
<input type="text" v-bind:value="name" />
11+
<h1>Events</h1>
12+
<button v-on:click="add(1)">Add a Year</button>
13+
<button v-on:click="subtract(1)">Subtract a Year</button>
14+
<button v-on:dblclick="add(10)">Add 10 Years</button>
15+
<button v-on:dblclick="subtract(10)">Subtract 10 Years</button>
16+
<p>My age is {{age}}</p>
17+
<div id="canvas" v-on:mousemove="updateXY">{{ x }} , {{ y }}</div>
1418
</div>
1519
</body>
1620

styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#canvas{
2+
width: 600px;
3+
padding: 200px 20px;
4+
text-align: center;
5+
border: 1px solid #333;
6+
}

0 commit comments

Comments
 (0)