[英]Javascript Object inside array
是否可以在推送中推送数据? 我需要获取在标签中设置的COMPONENT NAME的值(请参见我的代码)
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**
})
]
}
}
]
})
要使用组件名称数组填充label
属性,请执行以下操作:
更换:
children:
{
label: [
value.product_info.product_components.map((value) => {
//console.log(value.component.component_name)
** I need to push all component name here**
})
]
}
附:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.