init pinia

This commit is contained in:
Antony Budianto
2025-01-03 17:37:54 +07:00
parent b0221e1d21
commit de425bd9e5
15 changed files with 241 additions and 34 deletions
+17 -3
View File
@@ -3,13 +3,27 @@
<h1>rmt/pages/contact/index.vue</h1>
<div>Contact index</div>
<div>
count: {{ count }}
<button type="button" @click="count++">increment+</button>
count: {{ count }} / counterFromPinia: {{ counter.$state.count }} <br />
<button type="button" @click="count++">increment+ local</button>
<button type="button" @click="handleIncrementPinia">
increment+ pinia
</button>
</div>
</div>
</template>
<script setup>
<script setup lang="ts">
import { useCounter } from "@/stores/counter"
const counter = useCounter()
const count = ref(0)
const emit = defineEmits<{
(e: "increment", count: number): void
}>()
const handleIncrementPinia = () => {
counter.increment()
emit("increment", counter.$state.count)
}
</script>
<style scoped>
.rmt {