摘要: state: getter(state,getters,rootSate, rootGetters) mutation(state) action(context),即action({dispatch, commit, getters, rootGetters}) 阅读全文
posted @ 2021-03-07 13:21 猫骨喵 阅读(116) 评论(0) 推荐(0) 编辑
摘要: action函数可以接收一个与store实例具有相同方法的属性context,这个属性中包括下面几部分: context:{ state, 等同于store.$state,若在模块中则为局部状态 rootState, 等同于store.$state,只存在模块中 commit, 等同于store.$ 阅读全文
posted @ 2021-03-07 13:12 猫骨喵 阅读(823) 评论(0) 推荐(0) 编辑
摘要: 当要给actions传入多个参数或函数时,以对象形式传入,即 const actions = { getAllProducts({commit}, {vm, cb}) { // 将shop.js里的getAllGoods请求并获取数据 shop.getAllGoods(vm, products => 阅读全文
posted @ 2021-03-07 13:07 猫骨喵 阅读(1809) 评论(0) 推荐(0) 编辑