var Arry=[ {name: "vehicleTravelLicenseCopyBack", id: "a1"}, {name: "vehicleTravelLicenseCopyFront", id: "a2"}, {name: "idCardBack", id: "a3"}, {name: ...
var Arry=[
{name: "vehicleTravelLicenseCopyBack", id: "a1"},
{name: "vehicleTravelLicenseCopyFront", id: "a2"},
{name: "idCardBack", id: "a3"},
{name: "idCardFront", id: "a4"}
]
為了把上面的東西便成下麵的
var ImgObj={
idCardBack: "a1",
idCardFront: "a2",
vehicleTravelLicenseCopyBack: "a3",
vehicleTravelLicenseCopyFront: "a4"
}
- 以前的做法定義一個全量對象
2、我這是有多慘,今天才發現最快是這樣的
for (let v of Arry) {
imgObj[v.name] = v.id
}
為什麼當時用了兩個數組,腦子進水了。。。