1. After all, the parameter format needed in the backend is strange. After the front end has finished processing, it is found that the parameter format
this is the required parameter format
objobj
when it is submitted.
var obj ={
"1": {rate: "5", type_id: 2},
"2": {rate: "", type_id: 6},
"3": {rate: "4.2", type_id: ""},
"4": {rate: "2.1", type_id: ""}
}
obj
![][4]
var obj ={}
for (let i = 0; i < this.selectOptions.length; iPP) {
console.log(this.selectOptions[i])
obj["""+this.selectOptions[i].id+"""]={
"rate":this.selectOptions[i].rate !== ""?this.selectOptions[i].rate:"",
"type_id":this.selectOptions[i].selectValue !== ""?this.selectOptions[i].selectValue:"",
}
}
console.log(obj)
// console.log(Object.keys(obj)[0])
this.axios.post(this.submitUrl,{
data:obj
}).then(response=>{
if(response.data.code === 1){
}else{
Toast(response.data.msg)
}
}).catch(err=>{
Toast(err)
})
![][5]
data: {"1": {rate: "5", type_id: 2}, "2": {rate: "", type_id: 6}, "3": {rate: "4.2", type_id: ""}, }
"1": {rate: "5", type_id: 2}
"2": {rate: "", type_id: 6}
"3": {rate: "4.2", type_id: "}
" 4 ": {rate:" 2.1", type_id: ""}}