We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 396b2d8 commit d7f1d47Copy full SHA for d7f1d47
packages/playground/src/stores/demo-counter.ts
@@ -0,0 +1,11 @@
1
+import { defineStore, acceptHMRUpdate } from 'pinia'
2
+
3
+export const useCounter = defineStore('counter', {
4
+ state: () => ({
5
+ n: 0,
6
+ }),
7
+})
8
9
+if (import.meta.hot) {
10
+ import.meta.hot.accept(acceptHMRUpdate(useCounter, import.meta.hot))
11
+}
packages/playground/src/views/DemoCounter.vue
@@ -0,0 +1,21 @@
+<template>
+ <h2>Counter Store</h2>
+ <p>Counter :{{ counter.n }}. Double: {{ counter.double }}</p>
+ <button @click="counter.n++">Increment</button>
+ <hr />
+ <p>
+ <code>counter.$state</code>:
12
+ </p>
13
14
+ <pre>{{ counter.$state }}</pre>
15
+</template>
16
17
+<script lang="ts" setup>
18
+import { useCounter } from '../stores/demo-counter'
19
20
+const counter = useCounter()
21
+</script>
0 commit comments