diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/App.vue b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/App.vue
new file mode 100644
index 0000000..2ab91da
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/App.vue
@@ -0,0 +1,13 @@
+
+
+ OptionsAPI
+ |
+ CompositionAPI
+
+
+
+
+
+
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/main.js b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/main.js
new file mode 100644
index 0000000..225b6e1
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/main.js
@@ -0,0 +1,6 @@
+import {createApp} from "vue";
+import App from "./App.vue"
+import router from './router'
+import store from './store'
+
+createApp(App).use(router).use(store).mount('#app')
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/router/index.js b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/router/index.js
new file mode 100644
index 0000000..619eba5
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/router/index.js
@@ -0,0 +1,32 @@
+// 引入必要的router组件
+import {createRouter, createWebHistory} from 'vue-router'
+// 引入视图
+const OptionsAPI = () => import('../views/OptionsAPIView.vue')
+const CompositionAPI = () => import('../views/CompositionAPIView.vue')
+
+// 引入组件
+
+
+// 创建路由
+const routes = [
+ {
+ path: '/options',
+ name: 'options',
+ component: OptionsAPI
+ },
+ {
+ path: '/composition',
+ name: 'composition',
+ component: CompositionAPI
+ },
+]
+
+// 创建路由器,使用createRouter方法,传入history(路由类型)和 创建好的路由routes
+// 路由类型分为hash型和html5型,分别为createWebHashHistory和createWebHistory
+const router = createRouter({
+ history: createWebHistory(),
+ routes
+})
+
+// 导出路由
+export default router
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/index.js b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/index.js
new file mode 100644
index 0000000..80e7265
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/index.js
@@ -0,0 +1,37 @@
+import {createStore} from "vuex";
+import {moduleA} from "@/store/modules/ModuleA";
+import {moduleB} from "@/store/modules/ModuleB";
+
+export default createStore({
+ modules: {
+ module_a: moduleA,
+ module_b: moduleB,
+ },
+ state: {
+ count: 3,
+ },
+ getters: {
+ // getter使用箭头函数来定义,默认必传参数时state,如果需要其余参数,可以使用嵌套头函数
+ getter: (state) => (n) => {
+ return state.count * n;
+ },
+ },
+ mutations: {
+ // payload用于携带参数
+ mutation(state, payload) {
+ state.count += payload.num
+ }
+ },
+ actions: {
+ action(content, payload) {
+ // 模拟异步操作
+ setTimeout(() => {
+ // rep 模拟axios请求返回的数据
+ const rep = 3;
+ if (content.state.count > 50) {
+ content.commit('mutation', {num: rep + payload.num});
+ }
+ }, 1000)
+ }
+ }
+})
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleA.js b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleA.js
new file mode 100644
index 0000000..00d45c5
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleA.js
@@ -0,0 +1,22 @@
+export const moduleA = {
+ state: {
+ state_a: 1,
+ },
+ getters: {
+ getter_a: (state) => {
+ return state.state_a + 10;
+ }
+ },
+ mutations: {
+ mutation_a(state, payload) {
+ state.state_a += payload.num;
+ }
+ },
+ actions: {
+ action_a(content, payload) {
+ if (content.state.state_a > 50) {
+ content.commit('mutation_a', {num: payload.num})
+ }
+ }
+ }
+}
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleB.js b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleB.js
new file mode 100644
index 0000000..78412a5
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/store/modules/ModuleB.js
@@ -0,0 +1,23 @@
+export const moduleB = {
+ namespaced: true,
+ state: {
+ state_b: 2,
+ },
+ getters: {
+ getter_b: (state) => {
+ return state.state_b + 10;
+ }
+ },
+ mutations: {
+ mutation_b: (state, payload) => {
+ state.state_b += payload.num;
+ }
+ },
+ actions: {
+ action_b: (content, payload) => {
+ if (content.state.state_b > 50) {
+ content.commit('mutation_b', {num: payload.num})
+ }
+ },
+ }
+}
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/CompositionAPIView.vue b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/CompositionAPIView.vue
new file mode 100644
index 0000000..093c864
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/CompositionAPIView.vue
@@ -0,0 +1,79 @@
+
+
+ 对state的操作
+ 根-store.state.count: {{ store.state.count }}
+ A-store.state.state_a: {{ store.state.module_a.state_a }}
+ B-store.state.module_b.state_b: {{ store.state.module_b.state_b }}
+
+
+ 对getters的操作
+ 根-store.getters.getter(3): {{ store.getters.getter(3) }}
+ A-store.getters.getter_a: {{ store.getters.getter_a }}
+ B-store.getters['module_b/getter_b']: {{ store.getters['module_b/getter_b'] }}
+
+
+ 对mutations的操作
+ 根-store.commit('mutation', {num: 7}):
+
+
+ A-store.commit('mutation_a', {num: 8}):
+
+
+ B-store.commit('module_b/mutation_b', {num: 9}):
+
+
+
+
+ 对actions的操作
+ 根-store.dispatch('action', {num: 7}):
+
+
+ A-store.dispatch('action_a', {num: 8}):
+
+
+ B-store.dispatch('module_b/action_b', {num: 9}):
+
+
+
+
+
+
+
diff --git a/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/OptionsAPIView.vue b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/OptionsAPIView.vue
new file mode 100644
index 0000000..afef248
--- /dev/null
+++ b/demo/vuex-mapState-mapGetters-mapMutations-mapActions/views/OptionsAPIView.vue
@@ -0,0 +1,150 @@
+
+
+ 对state的操作
+ 根-count: {{ count }}
+ A-state_a: {{ state_a }}
+ B-state_b: {{ state_b }}
+
+
+ 对getters的操作
+ 根-getter(3): {{ getter(3) }}
+ A-getter_a: {{ getter_a }}
+ B-getter_b: {{ getter_b }}
+
+
+ 对mutations的操作
+ 根-@click="mutation({num: 7})":
+
+
+ A-@click="mutation_a({num: 8})":
+
+
+ B-@click="mutation_b({num: 9})":
+
+
+
+
+ 对actions的操作
+ 根-@click="action({num: 7})":
+
+
+ A-@click="action_a({num: 8})":
+
+
+ B-@click="action_b({num: 9})":
+
+
+
+ 混合用法
+ state_b_getter_a: (state, getters) => state.module_b.state_b + getters.getter_a: {{
+ state_b_getter_a
+ }}
+ state_a_getter_b: (state, getters) => state.module_a.state_a + getters["module_b/getter_b"]: {{
+ state_a_getter_b
+ }}
+ state_b_getter_b: (state, getters) => state.state_b + getters.getter_b: {{ state_b_getter_b }}
+
+ @click="mutation_a_count(100):
+
+
+ @click="action_b_count(200):
+
+
+
+
+
+
+
+