vuex actions传多个参数或函数
当要给actions传入多个参数或函数时,以对象形式传入,即
const actions = { getAllProducts({commit}, {vm, cb}) { // 将shop.js里的getAllGoods请求并获取数据 shop.getAllGoods(vm, products => { commit('setProducts', products) cb(products) }) } }
this.$store.dispatch('goods/getAllProducts', {vm, getgoods: (res) => { console.log(res) this.$nextTick(()=>{ freshWidth(el.children[0]); this.scroller.refresh(); }) }})