Javascript 如何使用Vuex命名空间模块和Vue Composition API获得多个操作和状态?

Javascript 如何使用Vuex命名空间模块和Vue Composition API获得多个操作和状态?,javascript,vue.js,vuex,vue-composition-api,Javascript,Vue.js,Vuex,Vue Composition Api,使用Vue Options API,我通过执行以下操作来获取操作和状态: computed: { ...mapState("myStore", ["myState", "myOtherState"]), }, methods: { ...mapActions("myStore", ["myAction", "myOtherAction"]), }

使用Vue Options API,我通过执行以下操作来获取操作和状态:

  computed: {
    ...mapState("myStore", ["myState", "myOtherState"]),
  },
  methods: {
    ...mapActions("myStore", ["myAction", "myOtherAction"]),
  }
我的问题是如何使用Vuex和Vue Composition API获得多个名称空间的操作和状态? 现在我有一个名为useStoreModule.js的包装器,看起来像这样:

import { createNamespacedHelpers } from "vuex-composition-helpers/dist";

export default function () {
  function getState(module, name) {
    const { useState } = createNamespacedHelpers(module);
    return useState([name]);
  }
  function getAction(module, name) {
    const { useActions } = createNamespacedHelpers(module);
    return useActions([name]);
  }
  return {
    getState,
    getAction,
  };
}
并通过执行以下操作获取状态/操作:

setup() {
    const { getState } = useStoreModule();
    const { myState } = getState("myStore", "myState");
}
那么,如何编写包装器来实现这一点:

setup() {
    const { getState } = useStoreModule();
    const { myState, myOtherState, myOtherOtherState } = getState("myStore", ["myState", "myOtherState", "myOtherOtherState"]);
}

感谢您的帮助:)

这是一种方法:

component.vue

  import { getCurrentInstance } from 'vue';

  setup() {
    const _instance = getCurrentInstance();
    const { $store } = _instance.appContext.app.config.globalProperties;
  },
createStore

"use strict";
import { createStore } from 'vuex';

// Stores
import moduleA from '@/store/moduleA.js';
import moduleB from '@/store/moduleB.js';

export const store = createStore({
  strict: true,
  modules: {
    moduleA,
    moduleB,
  }
});