I have an array like this:
campaigns = [
{id: 1, adGroups: [{id: 1, title: 'Hello'}, {id: 2, title: 'Hello'}]},
{id: 2, adGroups: [{id: 3, title: 'Hello'}, {id: 4, title: 'Hello'}]},
];
I render the array using v-for:
<fieldset class="mb-3 p-3 rounded border" v-for="(campaign, index) in campaigns" :key="index">
<fieldset class="mb-3 p-3 rounded border" v-for="(campaignAdGroup, indexAdGroup) in campaign.adGroups" :key="indexAdGroup">
{{ campaignAdGroup.title }}
</fieldset>
</fieldset>
It's fine, but now I want to add a new item to the campaign.adGroups, but it seems it doesn't work.
I have used the $set function to add new items to the array but it doesn't work.
this.$set(this.ruleCampaigns[index].adGroups, this.ruleCampaigns[index].adGroups.length, {id: null, title: ''})
How can I handle this case in VUE?
Thank you!
this.ruleCampaigns[index].adGroups.push({id: null, data: {bid: ''}})?