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

 

posted @ 2021-03-07 13:07  猫骨喵  阅读(1809)  评论(0编辑  收藏  举报