Skip to content

Commit f748e6c

Browse files
committed
Exercise 4.3
1 parent eceda80 commit f748e6c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script src="../node_modules/vue/dist/vue.js"></script>
22

3-
<div>
3+
<div id="app">
44
<counter></counter>
55
<counter></counter>
66
<counter></counter>
@@ -11,15 +11,29 @@
1111
// copy and modify the first exercise to use a Vue instance as
1212
// a shared store instead.
1313
const state = new Vue({
14-
// Implement this!
14+
data: {
15+
count: 0
16+
},
17+
methods: {
18+
inc () {
19+
this.count++
20+
}
21+
}
1522
})
1623

1724
const Counter = {
18-
// Implement this!
25+
render: h => h('div', state.count)
1926
}
2027

2128
new Vue({
2229
el: '#app',
23-
// Implement this!
30+
components: {
31+
Counter
32+
},
33+
methods: {
34+
inc () {
35+
state.inc()
36+
}
37+
}
2438
})
2539
</script>

0 commit comments

Comments
 (0)