Vuex的actions传递多个参数

Vuex dispatch的payload最多只能接收一个参数

参考:https://vuex.vuejs.org/api/#dispatch

1
2
3
4
var params = {}
params.name = name
params.age = age
self.$store.dispatch('userUpdate', {'schoolCode': this.id, 'params': params})
1
2
3
4
5
6
7
8
9
10
actions: {
// 更新用户信息
userUpdate ({ commit }, object) {
api.user_update(object.id, object.params).then((response) => {
commit(types.COMMON_USER_UPDATE_CALLBACK, {'httpCode': response.status, 'data': response.data})
}).catch((response) => {
commit(types.COMMON_USER_UPDATE_CALLBACK, {'httpCode': response.status, 'data': response.data, 'localMsg': object.params.localMsg})
})
}
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :