File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 1
1
new Vue ( {
2
2
el : '#vue-app' ,
3
3
data : {
4
- name : 'Shaun' ,
5
- job : 'Ninja' ,
6
- website : 'http://www.thenetninja.co.uk'
4
+ age : 25 ,
5
+ x : 0 ,
6
+ y : 0
7
7
} ,
8
8
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 ;
11
18
}
12
19
}
13
20
} ) ;
Original file line number Diff line number Diff line change 8
8
</ head >
9
9
< body >
10
10
< 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 >
14
18
</ div >
15
19
</ body >
16
20
Original file line number Diff line number Diff line change
1
+ # canvas {
2
+ width : 600px ;
3
+ padding : 200px 20px ;
4
+ text-align : center;
5
+ border : 1px solid # 333 ;
6
+ }
You can’t perform that action at this time.
0 commit comments