|
|
@@ -1,7 +1,8 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<h1>计数器</h1>
|
|
|
- <h3>初始值:{{ sum }}</h3>
|
|
|
+ <h3>初始值:{{ sum }},变大十倍:{{ bigSum }}</h3>
|
|
|
+ <button @click="changeAdd">增加</button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -9,9 +10,16 @@
|
|
|
import {ref,reactive} from "vue";
|
|
|
import {useCountStore} from '@/store/count';
|
|
|
import {storeToRefs} from 'pinia';
|
|
|
-// console.log(useCountStore())
|
|
|
+console.log(useCountStore())
|
|
|
const countStore = useCountStore();
|
|
|
-let {sum} = storeToRefs(countStore);
|
|
|
+let {sum,bigSum} = storeToRefs(countStore);
|
|
|
+function changeAdd() {
|
|
|
+ // sum.value++;
|
|
|
+ // countStore.add();
|
|
|
+ countStore.$patch({
|
|
|
+ sum:countStore.sum+10
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|