From ce0122a287f88e97d59e9f5e7def1c6a5f763c0f Mon Sep 17 00:00:00 2001 From: roger Date: Thu, 16 Feb 2023 14:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90vuex=E4=B8=AD=E7=9A=84getters?= =?UTF-8?q?=EF=BC=8CmapState=EF=BC=8CmapGetters=EF=BC=8CmapActions?= =?UTF-8?q?=E5=92=8CmapMutations=E7=9A=84=E5=AD=A6=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vue_code/src/components/Count.vue | 41 +++++++++++-------- 20_脚手架/vue_code/src/store/index.js | 12 +++++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/20_脚手架/vue_code/src/components/Count.vue b/20_脚手架/vue_code/src/components/Count.vue index 4a8b18f..8dd2603 100644 --- a/20_脚手架/vue_code/src/components/Count.vue +++ b/20_脚手架/vue_code/src/components/Count.vue @@ -1,19 +1,23 @@ \ No newline at end of file diff --git a/20_脚手架/vue_code/src/store/index.js b/20_脚手架/vue_code/src/store/index.js index f4061aa..e7a1f9a 100644 --- a/20_脚手架/vue_code/src/store/index.js +++ b/20_脚手架/vue_code/src/store/index.js @@ -32,7 +32,16 @@ const mutations = { } //准备state-用于存储数据 const state = { - sum: 0 + sum: 0, + school: '修仙学院', + subject: '修仙' +} + +// getters 用于对state中的数据进行加工,类似用computed +const getters = { + bigSum(state) { + return state.sum * 10 + } } // 创建并导出store @@ -40,4 +49,5 @@ export default new Vuex.Store({ actions, mutations, state, + getters })