1.數(shù)據(jù)源
array: [{
code: 'abc',
stand: 'a',
children: [{
height: 'air',
age: 19
},
{
height: 'ai',
age: 20
}
]
},
{
code: 'ssb',
stand: 'uup',
children: [{
height: 'jordan',
age: 19
},
{
height: 'IIP',
age: 20
}
]
}
]
2.數(shù)據(jù)賦值
this.ss = this.handleData(this.array);
3.函數(shù)定義
handleData(array) {
return array.map(item => {
const obj = {
name: item.code,
stand: item.stand
};
obj.children = item.children.map(subItem => ({
text: '智能機(jī)',
value1: subItem.height,
value2: subItem.age
}));
return obj;
})
}