在Vue中一般這樣使用loading狀態(tài)getData(){ this.loading = true; get(api).then(res => { this.data = res; this.loading = false;
})
}但在vuex的action中如何使用,下面例子使用了一個公共的loading發(fā)現(xiàn)不行,loading狀態(tài)應該是局部的,那么如何在vuex中控制loading狀態(tài)? const actions = {
getProductInfo({commit}){
commit(types.LOADING, true)
api.xxx()
.then(res => {
commit(types.PRODUCTINFO, res.data)
commit(types.LOADING, false)
})
},
vue如何在action中使用loading
ibeautiful
2018-11-07 13:17:41