Skip to content

Instantly share code, notes, and snippets.

View bin-r00t's full-sized avatar
👓

/r00t/bin bin-r00t

👓
  • undefined
  • Hanzhou, China
  • 22:14 (UTC +08:00)
View GitHub Profile
@bin-r00t
bin-r00t / component.vue
Last active May 30, 2024 06:37
vue3 - storeToRefs()
<script setup>
import { watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useCounterStore } from '@/stores/counter.js';
const store = useCounterStore();
const { count } = storeToRefs(store);
console.log('count===>', count);
// 这上面的 count 会不会随着 store 里 count 的更新而自动响应?
// 答: 经实践,会。而且不论 store 是用 选项方式 定义的还是 组合函数方式 定义的