We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a85417c commit 8f144f0Copy full SHA for 8f144f0
template/config/pinia/src/stores/counter.js
@@ -1,16 +1,12 @@
1
+import { ref, computed } from 'vue'
2
import { defineStore } from 'pinia'
3
-export const useCounterStore = defineStore({
4
- id: 'counter',
5
- state: () => ({
6
- counter: 0
7
- }),
8
- getters: {
9
- doubleCount: (state) => state.counter * 2
10
- },
11
- actions: {
12
- increment() {
13
- this.counter++
14
- }
+export const useCounterStore = defineStore('counter', () => {
+ const count = ref(0)
+ const doubleCount = computed(() => count.value * 2)
+ function increment() {
+ count.value++
15
}
+
+ return { count, doubleCount, increment }
16
})
0 commit comments