File tree Expand file tree Collapse file tree 2 files changed +35
-14
lines changed Expand file tree Collapse file tree 2 files changed +35
-14
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <select v-model =" type" >
4
+ <option value =" dice" >Board Game</option >
5
+ <option value =" spades" >Card Game</option >
6
+ </select >
7
+ <input v-model =" name" @keyup.enter =" add" >
8
+ <button @click =" add" >Add</button >
9
+ </div >
10
+ </template >
11
+
12
+ <script >
13
+ module .exports = {
14
+ data : function () {
15
+ return {
16
+ name: ' ' ,
17
+ type: ' dice' ,
18
+ }
19
+ },
20
+ methods: {
21
+ add : function () {
22
+ this .$emit (' add' , {
23
+ name: this .name ,
24
+ type: this .type
25
+ })
26
+ }
27
+ }
28
+ }
29
+ </script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <select v-model =" type" >
4
- <option value =" dice" >Board Game</option >
5
- <option value =" spades" >Card Game</option >
6
- </select >
7
- <input v-model =" game" @keyup.enter =" addGame" >
8
- <button @click =" addGame" >Add</button >
3
+ <board-add @add =" handleAdd" ></board-add >
9
4
<p v-if =" empty" >Zarro Boords!</p >
10
5
<ul v-else >
11
- <board-game v-for =" g in games" :type =" g .type" :name =" g. game" ></board-game >
6
+ <board-game v-for =" game in games" :type =" game .type" :name =" game.name " ></board-game >
12
7
</ul >
13
8
</div >
14
9
</template >
15
10
16
11
<script >
12
+ var BoardAdd = require (' ./BoardAdd.vue' )
17
13
var BoardGame = require (' ./BoardGame.vue' )
18
14
19
15
module .exports = {
20
16
data : function () {
21
17
return {
22
- game: ' ' ,
23
- type: ' dice' ,
24
18
games: []
25
19
}
26
20
},
@@ -30,14 +24,12 @@ module.exports = {
30
24
}
31
25
},
32
26
methods: {
33
- addGame : function () {
34
- this .games .push ({
35
- game: this .game ,
36
- type: this .type
37
- })
27
+ handleAdd : function (game ) {
28
+ this .games .push (game)
38
29
}
39
30
},
40
31
components: {
32
+ BoardAdd: BoardAdd,
41
33
BoardGame: BoardGame
42
34
}
43
35
}
You can’t perform that action at this time.
0 commit comments