From 2f937141f887e09b58aaabb3c9d97aef96b2b6b9 Mon Sep 17 00:00:00 2001 From: roger_home_pc Date: Wed, 20 Sep 2023 21:58:25 +0800 Subject: [PATCH] =?UTF-8?q?vuex=E4=B8=B4=E6=97=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.js | 6 ++++++ src/views/CompositionAPIView.vue | 21 ++++++++++++++++++++- src/views/OptionsAPIView.vue | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 4f8f73b..1b46523 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -12,5 +12,11 @@ export default createStore({ moreCount: (state) => (n) => { return state.count * n } + }, + mutations: { + // payload用于携带参数 + increment(state, payload) { + state.count += payload.num + } } }) diff --git a/src/views/CompositionAPIView.vue b/src/views/CompositionAPIView.vue index 81eca08..2993e76 100644 --- a/src/views/CompositionAPIView.vue +++ b/src/views/CompositionAPIView.vue @@ -1,17 +1,36 @@ diff --git a/src/views/OptionsAPIView.vue b/src/views/OptionsAPIView.vue index 9dcdb48..9773e44 100644 --- a/src/views/OptionsAPIView.vue +++ b/src/views/OptionsAPIView.vue @@ -1,17 +1,40 @@