Added Pinia store

This commit is contained in:
CharlieDigital
2022-01-15 13:41:04 -05:00
parent 32a4fd15e2
commit 522d0712fd
2 changed files with 12 additions and 3 deletions

View File

@@ -1,9 +1,9 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useAppState } from '../stores/appState'
defineProps<{ msg: string }>()
const count = ref(0)
const appState = useAppState();
</script>
<template>
@@ -27,7 +27,7 @@ const count = ref(0)
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<button type="button" @click="count++">count is: {{ count }}</button>
<button type="button" @click="appState.counter++">count is: {{ appState.counter }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.

View File

@@ -0,0 +1,9 @@
import { defineStore } from 'pinia';
export const useAppState = defineStore('appState', {
state: () => {
return {
counter: 0
}
}
});