File tree Expand file tree Collapse file tree 8 files changed +220
-0
lines changed Expand file tree Collapse file tree 8 files changed +220
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > Document</ title >
8
+ </ head >
9
+ < body >
10
+ < h1 > My App</ h1 >
11
+ < div id ="app "> </ div >
12
+
13
+ < script src ="https://unpkg.com/vue "> </ script >
14
+ < script src ="./main.js "> </ script >
15
+ </ body >
16
+ </ html >
Original file line number Diff line number Diff line change
1
+ const app = new Vue ( {
2
+ el : "#app" ,
3
+ data : {
4
+ bobby : {
5
+ name : "Bobby Boone" ,
6
+ age : 25
7
+ } ,
8
+ john : {
9
+ name : "John Boby" ,
10
+ age : 35 ,
11
+ }
12
+ } ,
13
+ template : `
14
+ <div>
15
+ <h2>Name: {{john.name}}</h2>
16
+ <h2>Age: {{john.age}}</h2>
17
+ <h2>Name: {{bobby.name}}</h2>
18
+ <h2>Age: {{bobby.age}}</h2>
19
+ </div>
20
+ `
21
+ } )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > Document</ title >
8
+ </ head >
9
+ < body >
10
+ < h1 > My App</ h1 >
11
+ < div id ="app "> </ div >
12
+
13
+ < script src ="https://unpkg.com/vue "> </ script >
14
+ < script src ="./main.js "> </ script >
15
+ </ body >
16
+ </ html >
Original file line number Diff line number Diff line change
1
+ const app = new Vue ( {
2
+ el : "#app" ,
3
+ data : {
4
+ bobby : {
5
+ first : "Bobby" ,
6
+ last : "Boone" ,
7
+ age : 25
8
+ } ,
9
+ john : {
10
+ first : "John" ,
11
+ last : "Boone" ,
12
+ age : 35 ,
13
+ }
14
+ } ,
15
+ computed : {
16
+ johnAgeInOneYear ( ) {
17
+ return this . john . age + 1 ;
18
+ }
19
+ } ,
20
+ filters : {
21
+ ageInOneYear ( age ) {
22
+ return age + 1 ;
23
+ } ,
24
+ fullName ( value ) {
25
+ return `${ value . last } , ${ value . first } ` ;
26
+ }
27
+ } ,
28
+ template : `
29
+ <div>
30
+ <h2>Name: {{john | fullName}}</h2>
31
+ <h2>Age: {{john.age | ageInOneYear}}</h2>
32
+ <h2>Name: {{bobby | fullName}}</h2>
33
+ <h2>Age: {{bobby.age | ageInOneYear}}</h2>
34
+ </div>
35
+ `
36
+ } )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > Document</ title >
8
+ </ head >
9
+ < body >
10
+ < h1 > My App</ h1 >
11
+ < div id ="app "> </ div >
12
+
13
+ < script src ="https://unpkg.com/vue "> </ script >
14
+ < script src ="./main.js "> </ script >
15
+ </ body >
16
+ </ html >
Original file line number Diff line number Diff line change
1
+ const app = new Vue ( {
2
+ el : "#app" ,
3
+ data : {
4
+ friends : [
5
+ {
6
+ first : "Bobby" ,
7
+ last : "Boone" ,
8
+ age : 25
9
+ } ,
10
+ {
11
+ first : "John" ,
12
+ last : "Boone" ,
13
+ age : 35 ,
14
+ }
15
+ ] ,
16
+ } ,
17
+ filters : {
18
+ ageInOneYear ( age ) {
19
+ return age + 1 ;
20
+ } ,
21
+ fullName ( value ) {
22
+ return `${ value . last } , ${ value . first } ` ;
23
+ }
24
+ } ,
25
+ methods : {
26
+ decrementAge ( friend ) {
27
+ friend . age = friend . age - 1 ;
28
+ } ,
29
+ incrementAge ( friend ) {
30
+ friend . age = friend . age + 1 ;
31
+ } ,
32
+ } ,
33
+ template : `
34
+ <div>
35
+ <h2 v-for="friend in friends">
36
+ <h4>{{friend | fullName}}</h4>
37
+ <h5>age: {{friend.age}}</h5>
38
+ <button v-on:click="decrementAge(friend)">-</button>
39
+ <button v-on:click="incrementAge(friend)">+</button>
40
+ <input v-model="friend.first"/>
41
+ <input v-model="friend.last"/>
42
+ </h2>
43
+ </div>
44
+ `
45
+ } )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > Document</ title >
8
+ </ head >
9
+ < body >
10
+ < h1 > My App</ h1 >
11
+ < div id ="app "> </ div >
12
+
13
+ < script src ="https://unpkg.com/vue "> </ script >
14
+ < script src ="./main.js "> </ script >
15
+ </ body >
16
+ </ html >
Original file line number Diff line number Diff line change
1
+ Vue . component ( 'friend-component' , {
2
+ props : [ 'friend' ] ,
3
+ filters : {
4
+ ageInOneYear ( age ) {
5
+ return age + 1 ;
6
+ } ,
7
+ fullName ( value ) {
8
+ return `${ value . last } , ${ value . first } ` ;
9
+ }
10
+ } ,
11
+ methods : {
12
+ decrementAge ( friend ) {
13
+ friend . age = friend . age - 1 ;
14
+ } ,
15
+ incrementAge ( friend ) {
16
+ friend . age = friend . age + 1 ;
17
+ } ,
18
+ } ,
19
+ template : `
20
+ <div>
21
+ <h4>{{friend | fullName}}</h4>
22
+ <h5>age: {{friend.age}}</h5>
23
+ <button v-on:click="decrementAge(friend)">-</button>
24
+ <button v-on:click="incrementAge(friend)">+</button>
25
+ <input v-model="friend.first"/>
26
+ <input v-model="friend.last"/>
27
+ </div>
28
+ `
29
+ } ) ;
30
+
31
+
32
+
33
+ const app = new Vue ( {
34
+ el : "#app" ,
35
+ data : {
36
+ friends : [
37
+ {
38
+ first : "Bobby" ,
39
+ last : "Boone" ,
40
+ age : 25
41
+ } ,
42
+ {
43
+ first : "John" ,
44
+ last : "Boone" ,
45
+ age : 35 ,
46
+ }
47
+ ] ,
48
+ } ,
49
+ template : `
50
+ <div>
51
+ <friend-component v-for="item in friends" v-bind:friend="item" />
52
+ </div>
53
+ `
54
+ } )
You can’t perform that action at this time.
0 commit comments