首先引入lodash
import _ from 'lodash';
map方法使用
// 数据源的数组
this.prototypes = [
{
id: 0,
fieldName: 'type',
fieldDescription: '设备类型字段,不可修改',
mustNeed: true,
vVisible: true
},
{
id: 1,
fieldName: 'id',
fieldDescription: '设备唯一标识符,同类型设备不允许',
mustNeed: true,
vVisible: true
},
{
id: 2,
fieldName: 'fieldName',
fieldDescription: '设备名称',
mustNeed: true,
vVisible: true
},
{
id: 3,
fieldName: 'tmp',
fieldDescription: '温度',
mustNeed: true,
vVisible: true
}
];
// _.map(遍历的数组, 取的数据源名称)
const exitNames = _.map(this.prototypes, 'fieldName');
exitNames.pop(); // 去除头部,只返回最后一个函数,即将fieldName:这个头部删除
this.prototypesCopy = _.map(this.prototypes, 'fieldName');