【发布时间】:2021-11-03 17:45:14
【问题描述】:
这是我的组件
methods:{
...mapActions(['udpateUsers']),
Update(userID){
let formData = new FormData();
formData.append('new_name',this.editUser.new_name);
formData.append('_method', 'PUT');
let config = {
headers:{
'Content-Type':'multipart/form-data',
}
}
this.udpateUsers(userID,formData,config);
}
当我点击更新按钮时,formData 无法发送到服务器,但是当我控制台它时,FormData 包含所有字段
这是我的模块
mutations:{
ADD_USER: (state,response)=>{
state.Users = response;
},
UPDATE_USERS: (state,response)=>{
state.Users = response;
}
},
actions:{
udpateUsers: ({commit},userID,formData,config)=>{
http.put("/admin/update/"+userID,formData,config)
.then((response)=>{
commit("UPDATE_USERS",formData);
console.log(response);
})
.catch((error)=>{
console.log(error.response);
})
}
}
export default auth
我认为错误将是我的提交突变
【问题讨论】:
标签: vue.js vue-component vuex vuex-modules vuex-module-decorators