Skip to content

Commit d7f1d47

Browse files
committed
chore: add talk demo
1 parent 396b2d8 commit d7f1d47

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<h2>Counter Store</h2>
3+
4+
<p>Counter :{{ counter.n }}. Double: {{ counter.double }}</p>
5+
6+
<button @click="counter.n++">Increment</button>
7+
8+
<hr />
9+
10+
<p>
11+
<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

Comments
 (0)