想给对应的数组里添加对象,可是每次添加都会给所有的数组都添加,求帮助
data(){
pdiConclusionInfo: {
suggestLevelStr: 1,
resultStr: 0,
totalValueStr: '',
remark: '',
artificialDetails: [
{
'name': '',
'itemCode': '',
'amountStr': '',
'priceStr': '',
'totalValueStr': ''
}
],
componentDetails: [
{
'name': '',
'itemCode': '',
'amountStr': '',
'priceStr': '',
'totalValueStr': ''
}
],
materialDetails: [
{
'name': '',
'itemCode': '',
'amountStr': '',
'priceStr': '',
'totalValueStr': ''
}
]
}
}
addRow(e) {
console.log(e)
var obj = {
'name': '',
'itemCode': '',
'amountStr': '',
'priceStr': '',
'totalValueStr': ''
}
if(e.type == 'work'){
this.pdiConclusionInfo.artificialDetails.push(obj)
} else if(e.type == 'part'){
this.pdiConclusionInfo.componentDetails.push(obj)
} else if(e.type == 'accessory'){
this.pdiConclusionInfo.materialDetails.push(obj)
}
},
artificialDetails、componentDetails、materialDetails这三个应该是同一个数组数据,看下他们是怎么来的