如何将两个数组相对应添加到对象中传给后台

有enterpriseId:[2,3]和shopId:[1,2],要转换成下面这种

{
"enterpriseId": 2, 
"shopId": 1 
},
{
"enterpriseId": 2, 
"shopId": 2 
}
]

目前写法如下得到——[{enterpriseId: 2, shopId: 1}]

data: [
                                    {
                                    enterpriseId: parseInt(_vue.tempUser.enterpriseId.toString()),
                                    shopId: parseInt(_vue.tempUser.shopId.toString()) ,
                                }
                                ]

写个函数循环一下不就好了,生成一个新的数据集push进去

let enterpriseId = [2,3];
let shopId = [1, 2];
console.log(enterpriseId.map((item, i) => ({ enterpriseId: item, shopId: shopId[i] })))

img

有用请采纳