Skip to content

Commit a3b1e60

Browse files
committed
feat: use setup stores in pinia example
Closes #94
1 parent 490c86c commit a3b1e60

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

Diff for: template/config/pinia/src/stores/counter.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1+
import { ref, computed } from 'vue'
12
import { defineStore } from 'pinia'
23

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-
}
4+
export const useCounterStore = defineStore('counter', () => {
5+
const count = ref(0)
6+
const doubleCount = computed(() => count.value * 2)
7+
function increment() {
8+
count.value++
159
}
10+
11+
return { count, doubleCount, increment }
1612
})

0 commit comments

Comments
 (0)