uni-app开发小程序,往对象数组里添加对象,可是所有数组都会添加?

新手上路,请多包涵

想给对应的数组里添加对象,可是每次添加都会给所有的数组都添加,求帮助

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)
        }
    },
阅读 3.7k
1 个回答

artificialDetails、componentDetails、materialDetails这三个应该是同一个数组数据,看下他们是怎么来的