feat: Add persist option to useCounterStore
All checks were successful
CI / cache-and-install (push) Successful in 1m36s
All checks were successful
CI / cache-and-install (push) Successful in 1m36s
This commit is contained in:
@ -1,12 +1,18 @@
|
||||
import { ref, computed } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useCounterStore = defineStore('counter', () => {
|
||||
const count = ref(0);
|
||||
const doubleCount = computed(() => count.value * 2);
|
||||
function increment() {
|
||||
count.value++;
|
||||
}
|
||||
export const useCounterStore = defineStore(
|
||||
'counter',
|
||||
() => {
|
||||
const count = ref(0);
|
||||
const doubleCount = computed(() => count.value * 2);
|
||||
function increment() {
|
||||
count.value++;
|
||||
}
|
||||
|
||||
return { count, doubleCount, increment };
|
||||
});
|
||||
return { count, doubleCount, increment };
|
||||
},
|
||||
{
|
||||
persist: true,
|
||||
},
|
||||
);
|
||||
|
Reference in New Issue
Block a user