當要給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(); }) }})