这里是复制链接:https://stackblitz.com/edit/node-c6mn17?file=src/components/Test.vue
我希望能够使用 Vue 2.7 中的设置从该商店使用反应状态。
我使用
export const store = new Vuex.Store({ ... })
导出 Vuex 商店
这两个都失败了:
const count1 = store.state.count;
const count2 = ref(store.state.count);
将商店导出为功能时也不起作用:
export const useStore = () => store
并做useStore().state ...
使用计算:
import { computed } from "vue"
const count2 = computed(() => store.state.count);