Skip to content

Commit 43dcd9d

Browse files
committed
72
1 parent b98be79 commit 43dcd9d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/composables/count.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { reactive, toRefs } from 'vue'
2+
3+
export const useCount = () => {
4+
const state = reactive({
5+
count: 0
6+
});
7+
8+
return toRefs(state);
9+
}

src/pages/index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
<template>
22
<div>Home Page</div>
3+
<div>{{ count }}</div>
4+
<button @click="count++">Add</button>
35
</template>
46

57
<script>
8+
import { useCount } from '@/composables/count';
9+
610
export default {
11+
setup() {
12+
const { count } = useCount();
713
14+
return {
15+
count
16+
}
17+
}
818
}
919
</script>
1020

0 commit comments

Comments
 (0)