-
Notifications
You must be signed in to change notification settings - Fork 4
/
counter.vue
66 lines (58 loc) · 1.22 KB
/
counter.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
<div class="counter">
<h1>{{ counter }}</h1>
<small>number</small>
<div>
<button @click="inc">increment</button>
<button @click="desc">decrement</button>
</div>
</div>
</template>
<script>
import { computed } from "vue";
import { useBucket } from "../../dist/v-bucket.esm-browser.prod";
export default {
setup() {
const bucket = useBucket();
let counter = computed(() => {
return bucket.getters["counter/GET_COUNT"];
});
const inc = () => {
bucket.commit("counter/inc");
};
const desc = () => {
bucket.commit("counter/desc");
};
return {
counter,
inc,
desc
};
}
};
</script>
<style scoped lang="scss">
div.counter {
margin: 0 auto;
width: 500px;
height: 300px;
border: 1px solid #e9e9e9;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
h1 {
font-size: 90px;
margin: 0;
padding: 0;
}
small {
margin-bottom: 40px;
}
}
button {
cursor: pointer;
padding: 8px 30px;
margin: 5px;
}
</style>