const batch = ["401", "425", "430", "402", "403", "326", "429", "400", "446", "324"]
if (batch) {
let queryArr = []
var arr = []
for (var key in batch) {
if (batch[key]) {
queryArr.push(`${'branch'+key}=${batch[key]}`)
}
}
arr += `&${queryArr.join('&')}`
}
console.log(arr)
打印出来的样子如下展示:
&branch0=401&branch1=425&branch2=430&branch3=402&branch4=403&branch5=326&branch6=429&branch7=400&branch8=446&branch9=324