小编EaB*_*EaB的帖子

如何将 2 个 vuex 商店合并为一个商店

您好,我需要将 2 家vuex商店合并为一家商店(两家商店属于不同的项目

import storeA from '/path';

import storeB from '/path';
Run Code Online (Sandbox Code Playgroud)

现在合并了两家商店

const combinedStore = //combine logic as i don't know this logic
Run Code Online (Sandbox Code Playgroud)

我在 stackoverflow 上搜索了很多以合并 2 个 vuex 商店,但我没有找到任何发布的解决方案。

这是我的vuex商店在两个地方的样子stores

商店 1:

   // storeA.js
    
    const store = {
        state(){return {}},
        actions: {async getData(){...}},
        mutations: {},
        getters: {}, 
        modules:{ 
           Login
        }
    }
Run Code Online (Sandbox Code Playgroud)

商店2:

   // storeB.js
    
    const store = {
        state(){return {}},
        actions: {async getUsers(){...}},
        mutations: {},
        getters: {}, 
        modules:{ 
           workflow
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是我尝试的方法: …

vue.js vuex vuejs3

5
推荐指数
1
解决办法
1385
查看次数

标签 统计

vue.js ×1

vuejs3 ×1

vuex ×1