动态加载Vuex模块

Vuex is an easy to use and performant solution to handle state management. It makes it a breeze to manage large-scale Vue.js applications and ensures a predictable way to mutate the state by exposing a store.

Vuex是一种易于使用且性能卓越的解决方案,用于处理状态管理。 它使管理大型Vue.js应用程序变得轻而易举,并通过暴露商店来确保以可预测的方式改变状态的方式。

You may already know about Vuex, but if you don’t Joshua Bemenderfer gave us a great introduction.

您可能已经了解Vuex,但是如果您不了解Vuex,Joshua Bemenderfer会给我们提供很好的介绍

You can define modules in your Vuex store as follows:

您可以在Vuex存储中定义模块,如下所示:

const dogs = {
  state: {
    data: []
  },
  mutations: {
    addDog(state, dog) {
      state.data.push(dog)
    }
  }
}

const store = new Vuex.Store({
  modules: {
    dogs
  }
});

Usually a large application has several modules. All of them are defined statically in their own file, and combined together when calling new Vuex.Store. That’s what you should do in practically all cases.

通常,大型应用程序具有多个模块。 所有它们都在自己的文件

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值