取出对象数组中的 key value
2018-01-16 本文已影响0人
Sxy97
记录一下,最近常用这个
let date = [{name: "小明", age: "19"}, {name: "张三", age: "19"}, {name: "李四", age: "19"}]
for (let i = 0; i < date.length; i++) {
for (let [key, values] of Object.entries(date[i])) {
console.log(`key:${key} values:${values}`)
}
}
//得到的数据
key:name values:小明
key:age values:19
key:name values:张三
key:age values:19
key:name values:李四
key:age values:19