init source
This commit is contained in:
25
composables/useCounter.ts
Normal file
25
composables/useCounter.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export const useCounter = () => {
|
||||
const count = ref(0);
|
||||
|
||||
const increment = () => {
|
||||
count.value++;
|
||||
};
|
||||
|
||||
const decrement = () => {
|
||||
count.value--;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
count.value = 0;
|
||||
};
|
||||
|
||||
const double = computed(() => count.value * 2);
|
||||
|
||||
return {
|
||||
count: readonly(count),
|
||||
increment,
|
||||
decrement,
|
||||
reset,
|
||||
double,
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user