Home > Mobile >  How to push the object into the first array?
How to push the object into the first array?

Time:09-08

How can I push the Image object into the first array?

//Vue (my current code)
productList.value.push(res.data.returnData.info);
var a ='Image';
var obj={};
obj[a] = res.data.returnData.image[0].ppName;
productList.value.push(obj);

enter image description here

CodePudding user response:

As per the screenshot shared by you, I can see it's an array of objects. So you want to merge image object properties into first object ? If Yes, Here you go :

const imageObj = {
  image: 'Image URL'
};

productList.value[0] = Object.assign(productList.value[0], imageObj);
  • Related