数据格式转化
let data = { active: [1, 2, 3, 4, 5], disabled: [false, true, 3, 4, 5] } let final = [] let keys = Object.keys(data) // ['active', 'disabled'] let valueNum = data[keys[0]].length // 2 for(let j = 0; j < valueNum; j++) { let tempObj = {} // j = 1 for (let k = 0; k < keys.length; k++) { let param = keys[k] let tempValue = data[param] tempObj[param] = tempValue[j] } final.push(tempObj) } console.log(final)
DO What You Want !