-
map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。
-
//currentValue 必须。当前元素的值 // index 可选。当前元素的索引值 // arr 可选。当前元素属于的数组对象 // thisValue 可选。对象作为该执行回调时使用,传递给函数,用作 "this" 的值。 // 如果省略了 thisValue,或者传入 null、undefined,那么回调函数的 this 为全局对象。 array.map(function(currentValue,index,arr), thisValue)
data: {
Cates: [{name: 'a', age: 11}, {name: 'b', age: 22}]
},
let leftMenuList = this.Cates.map(v => v.name)
console.log(leftMenuList) // 结果为this.Cates数组中的name值 ['a', 'b']