Vue2-vuex
来源:
- Vue社区
- Vue官网
语法
- state 用于存储数据
- mutations 用户存改变state的方法
- 暴露变量:
const store = new Vuex.Store({ state, mutations }); - 注册到实例
this.$store. this.$store.commit();
来源:
const store = new Vuex.Store({
state,
mutations
});
this.$store.
this.$store.commit();