-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.vue
49 lines (47 loc) · 833 Bytes
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<div>
<p>
count:
<output>{{ count }}</output>
</p>
<p>
half:
<output>{{ half }}</output>
</p>
<button type="button" @click="increment">Increment</button>
<button type="button" @click="asyncIncrement">Async Increment</button>
</div>
</template>
<script>
export default {
props: {
name: {
type: String,
required: true
}
},
local () {
return {
name: this.name,
state: {
count: 0
},
getters: {
half: state => state.count / 2
},
actions: {
asyncIncrement ({ commit }) {
setTimeout(() => {
commit('increment')
}, 1000)
}
},
mutations: {
increment (state) {
state.count += 1
}
}
}
}
}
</script>