File tree 4 files changed +119
-22
lines changed
4 files changed +119
-22
lines changed Original file line number Diff line number Diff line change 2
2
<div id =" app" >
3
3
<div class =" sports-field" >
4
4
<h1 >{{ title }}</h1 >
5
- <img
6
- class =" soccer-goal"
7
- src =" /static/soccer-goal.png"
8
- alt =" Soccer goal" >
9
- <img
10
- class =" soccer-ball"
11
- :class =" status"
12
- src =" /static/soccer-ball.png"
13
- alt =" Soccer ball"
14
- @click =" shoot" >
5
+ <board :score =" score" :miss =" miss" ></board >
6
+ <goal ></goal >
7
+ <ball :image =" src" @score =" score ++" @miss =" miss ++" ></ball >
15
8
</div >
16
9
</div >
17
10
</template >
18
11
19
12
<script >
13
+ import Goal from ' ./components/Goal.vue'
14
+ import Ball from ' ./components/Ball.vue'
15
+ import Board from ' ./components/Board.vue'
16
+
20
17
export default {
18
+ components: {
19
+ Goal,
20
+ Ball,
21
+ Board
22
+ },
23
+
21
24
data () {
22
25
return {
26
+ score: 0 ,
27
+ miss: 0 ,
23
28
status: ' ' ,
24
- title: " Let's play"
29
+ title: " Getting started" ,
30
+ goalClass: " something-great" ,
31
+ src: ' /static/soccer-ball.png'
25
32
}
26
33
},
27
34
28
35
methods: {
29
- shoot () {
30
- const results = [
31
- ' miss' ,
32
- ' score'
33
- ]
34
-
35
- this .status = results[Math .floor (Math .random () * results .length )]
36
36
37
- setTimeout (() => {
38
- this .reset ()
39
- }, 800 )
40
- },
41
37
42
38
reset () {
43
39
this .status = ' reset'
44
40
setTimeout (() => {
45
41
this .status = ' '
46
42
}, 500 )
43
+ },
44
+
45
+ imageSrc () {
46
+ return ' /static/soccer-ball.png'
47
47
}
48
48
}
49
49
}
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <img
3
+ :class =" status"
4
+ @click =" shoot"
5
+ class =" soccer-ball"
6
+ :src =" image"
7
+ alt =" Soccer ball" >
8
+ </template >
9
+
10
+ <script >
11
+ export default {
12
+ data () {
13
+ return {
14
+ status: ' '
15
+ }
16
+ },
17
+
18
+ props: [
19
+ ' image'
20
+ ],
21
+
22
+ watch: {
23
+ status () {
24
+ if ( this .status == ' score' ) {
25
+ this .$emit (' score' )
26
+ } else if ( this .status == ' miss' ) {
27
+ this .$emit (' miss' )
28
+ }
29
+ }
30
+ },
31
+
32
+ methods: {
33
+ shoot () {
34
+ const results = [
35
+ ' miss' ,
36
+ ' score'
37
+ ]
38
+
39
+ this .status = results[Math .floor (Math .random () * results .length )]
40
+
41
+ setTimeout (() => {
42
+ this .reset ()
43
+ }, 800 )
44
+ },
45
+
46
+ reset () {
47
+ this .status = ' reset'
48
+ setTimeout (() => {
49
+ this .status = ' '
50
+ }, 500 )
51
+ },
52
+ }
53
+ }
54
+ </script >
55
+
56
+ <style >
57
+
58
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" board" >
3
+ <div class =" board-score" >
4
+ Score: {{ score }}
5
+ </div >
6
+ <div class =" board-miss" >
7
+ Miss: {{ miss }}
8
+ </div >
9
+ </div >
10
+ </template >
11
+
12
+ <script >
13
+ export default {
14
+ props: [
15
+ ' score' ,
16
+ ' miss'
17
+ ]
18
+ }
19
+ </script >
20
+
21
+ <style >
22
+
23
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <img
3
+ class =" soccer-goal"
4
+ src =" /static/soccer-goal.png"
5
+ alt =" Soccer goal" >
6
+ </template >
7
+
8
+ <script >
9
+ export default {
10
+
11
+ }
12
+ </script >
13
+
14
+ <style >
15
+
16
+ </style >
You can’t perform that action at this time.
0 commit comments