File tree Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change 8
8
< body >
9
9
< div id ="app ">
10
10
< select v-model ="type ">
11
- < option value ="icon- dice "> Board Game</ option >
12
- < option value ="icon- spades "> Card Game</ option >
11
+ < option value ="dice "> Board Game</ option >
12
+ < option value ="spades "> Card Game</ option >
13
13
</ select >
14
- < input v-model ="game ">
15
- < button @click ="games.push({game: game, type: type}) "> Add</ button >
16
- < p v-if ="games.length == 0 "> Zarro Boords!</ p >
14
+ < input v-model ="game " @keyup.enter =" addGame " >
15
+ < button @click ="addGame "> Add</ button >
16
+ < p v-if ="empty "> Zarro Boords!</ p >
17
17
< ul v-else >
18
18
< li v-for ="g in games ">
19
- < span :class ="g.type "> </ span >
19
+ < span :class ="icon( g.type) "> </ span >
20
20
{{ g.game }}
21
21
</ li >
22
22
</ ul >
27
27
el : '#app' ,
28
28
data : {
29
29
game : '' ,
30
- type : 'icon- dice' ,
30
+ type : 'dice' ,
31
31
games : [ ]
32
+ } ,
33
+ computed : {
34
+ empty : function ( ) {
35
+ return this . games . length == 0
36
+ }
37
+ } ,
38
+ methods : {
39
+ addGame : function ( ) {
40
+ this . games . push ( {
41
+ game : this . game ,
42
+ type : this . type
43
+ } )
44
+ } ,
45
+ icon : function ( type ) {
46
+ return 'icon-' + type
47
+ }
32
48
}
33
49
} )
34
50
</ script >
You can’t perform that action at this time.
0 commit comments