const aa: any = [ { employeeId: 1012, remarks: "", sort:1111, trainingCertificateName: "CCC", trainingCourse :"开发1", trainingDuration:"3个月" }, { employeeId: 1012, remarks: "", sort:222222222, trainingCertificateName: "高级开发工程师", trainingCourse :"开发1", trainingDuration:"3个月" } ] export const trainingExperienceList : IbasicInfo[] = [ { name: '排序', id: 8, prop: 'sort', value: '', type: 'text' }, { name: '培训课程名称', id: 0, prop: 'trainingCertificateName', value: '', type: 'text' }, { name: '培训课程', id: 1, prop: 'trainingCourse', value: '', type: 'text' }, { name: '培训时长', id: 2, prop: 'trainingDuration', value: '', type: 'text' }, { name: '培训成绩', id: 4, prop: 'trainingResults', value: '', type: 'text' }, { name: '培训开始时间', id: 5, prop: 'startTime', value: '', type: 'date' }, { name: '培训结束日期', id: 6, prop: 'endTime', value: '', type: 'date' }, { name: '备注', id: 7, prop: 'remarks', value: '', type: 'textarea' } ] trainingExperienceList的数组长度,根据aa数组长度变化,请代码示例
时间: 2024-02-14 12:27:20 浏览: 49
根据aa数组的长度,动态生成trainingExperienceList数组的代码示例如下:
```typescript
const aa: any = [
{
employeeId: 1012,
remarks: "",
sort:1111,
trainingCertificateName: "CCC",
trainingCourse :"开发1",
trainingDuration:"3个月"
},
{
employeeId: 1012,
remarks: "",
sort:222222222,
trainingCertificateName: "高级开发工程师",
trainingCourse :"开发1",
trainingDuration:"3个月"
}
]
const trainingExperienceList: IbasicInfo[] = aa.map((item, index) => {
return {
name: '排序',
id: 8,
prop: 'sort',
value: item.sort.toString(),
type: 'text'
},
{
name: '培训课程名称',
id: 0,
prop: 'trainingCertificateName',
value: item.trainingCertificateName,
type: 'text'
},
{
name: '培训课程',
id: 1,
prop: 'trainingCourse',
value: item.trainingCourse,
type: 'text'
},
{
name: '培训时长',
id: 2,
prop: 'trainingDuration',
value: item.trainingDuration,
type: 'text'
},
{
name: '培训成绩',
id: 4,
prop: 'trainingResults',
value: '',
type: 'text'
},
{
name: '培训开始时间',
id: 5,
prop: 'startTime',
value: '',
type: 'date'
},
{
name: '培训结束日期',
id: 6,
prop: 'endTime',
value: '',
type: 'date'
},
{
name: '备注',
id: 7,
prop: 'remarks',
value: item.remarks,
type: 'textarea'
}
});
```
根据aa数组的长度,会动态生成相应数量的trainingExperienceList数组项,每个项的值会根据aa数组中对应索引的对象属性值进行赋值。注意,上述代码中的IbasicInfo是根据你提供的代码片段进行猜测的接口类型,请根据实际情况进行调整。
阅读全文