摘要: 你可以在组件中使用 this.$store.commit('xxx') 提交 mutation,或者使用 mapMutations 辅助函数将组件中的 methods 映射为 store.commit 调用(需要在根节点注入 store) 辅助函数只能在选项式API中使用 <template> <h 阅读全文
posted @ 2023-07-13 12:50 商品部-林军 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Vuex 使用单一状态树,用一个对象就包含了全部的应用层级状态。至此它便作为一个“唯一数据源 ”而存在。这也意味着,每个应用将仅仅包含一个 store 实例 在 Vue 组件中获得 Vuex 状态 import { createStore } from 'vuex' const store = cr 阅读全文
posted @ 2023-07-13 11:40 商品部-林军 阅读(76) 评论(0) 推荐(0) 编辑