Front-end formData transfer parameters, sometimes need to transfer array objects, if you directly append an array object to the variable, the back-end cannot accept it.
const arr = [
{name: 'zxc', age: 10},
{name: 'ly', age: 20}
]
const fd = new FormData()
fd.append('address', arr)
correct way to pass parameters for
arr.forEach((value, index) => {
fd.append(`address[${index}].name`, value.name)
fd.append(`address[${index}].age`, value.age)
})
if it is a string or numeric array
const arr = [1, 2, 3, 4, 5]
arr.forEach((value, index) => {
fd.append(`address[${index}]`, value)
})
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。