+
+
当前求和为: {{ sum }}
+ 当前求和放大10倍后为: {{ bigSum }}
+ 我在{{ school }},学{{ subject }}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/main.js b/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/main.js
new file mode 100644
index 0000000..abf3e27
--- /dev/null
+++ b/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/main.js
@@ -0,0 +1,26 @@
+// 引入Vue
+import Vue from "vue";
+// 引入App
+import App from "./App";
+// 引入插件
+import vueResource from "vue-resource";
+
+import store from './store'
+
+// 设置Vue
+Vue.config.productionTip = false
+
+// 使用插件
+Vue.use(vueResource)
+
+// 实例化Vue
+new Vue({
+ components: {
+ App
+ },
+ render: h => h(App),
+ store,
+ beforeCreate() {
+ Vue.prototype.$bus = this // 安装全局事件总线
+ }
+}).$mount('#app')
diff --git a/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/store/index.js b/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/store/index.js
new file mode 100644
index 0000000..e7a1f9a
--- /dev/null
+++ b/20_脚手架/vue_code/24.src_求和案例_getters、mapState、mapGetters、mapActions、mapMulations/store/index.js
@@ -0,0 +1,53 @@
+// 用于创建vue中核心 store
+// 引入Vue
+import Vue from "vue";
+// 引入vuex
+import Vuex from 'vuex'
+
+// 应用Vuex插件
+Vue.use(Vuex)
+
+// 准备actions-用于响应组件中的动作,业务逻辑需要写到actions中
+const actions = {
+ vuexAddOdd(context, value) {
+ if (context.state.sum % 2) {
+ context.commit('vuexAdd', value)
+ }
+ },
+ vuexAddWait(context, value) {
+ setTimeout(() => {
+ context.commit('vuexAdd', value)
+ }, 1000
+ )
+ }
+}
+//准备mutations-用于操作数据
+const mutations = {
+ vuexAdd(state, value) {
+ state.sum += value
+ },
+ vuexSub(state, value) {
+ state.sum -= value
+ }
+}
+//准备state-用于存储数据
+const state = {
+ sum: 0,
+ school: '修仙学院',
+ subject: '修仙'
+}
+
+// getters 用于对state中的数据进行加工,类似用computed
+const getters = {
+ bigSum(state) {
+ return state.sum * 10
+ }
+}
+
+// 创建并导出store
+export default new Vuex.Store({
+ actions,
+ mutations,
+ state,
+ getters
+})