Is it possible to push data inside push? I need to get the value of COMPONENT NAME (see in my code) of set it in label
this.itemOfSelectedPDList.map((value, index) => {
this.data2.push({
label: value.product_info.product_name,
children: [
{
label: 'OO',
children:
{
label: [
value.product_info.product_components.map((value) => {
//console.log(value.component.component_name)
** I need to push all component name here**
})
]
}
}
]
})
To populate the label
property with an array of component names do:
Replace:
children:
{
label: [
value.product_info.product_components.map((value) => {
//console.log(value.component.component_name)
** I need to push all component name here**
})
]
}
With:
children:
value.product_info.product_components.map((value) => {
return {label: value.component_name};
})
let arr = [ { product_info: { product_name: 'hi', product_components: [{component_name: 'c1'}, {component_name: 'c2'}] }}]; var data2 = []; arr.map((value) => { data2.push({ label: value.product_info.product_name, children: [ { label: 'OO', children: value.product_info.product_components.map((value) => { return {label: value.component_name}; }) } ] }); }) console.log(data2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.