Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f068586

Browse files
feat: use setup stores in pinia example
Closes #94
1 parent 714ce5b commit f068586

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed
Lines changed: 8 additions & 12 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /