I have an array(rows) inside an array(tabs). I want to duplicate the the array. now how do I duplicate the rows array and tabs array separately. Like when I click "Add row" button a row will be added and when I click the "add tab" button the whole tab with row will be added. I am trying this way--
export default {
data() {
return {
tabs: [
{
selectedHouseType: "",
rows: [
{
decorTypes: {},
selectedDecor: "",
selectedDes: "",
selectedQty: "",
selectedRate: "",
line_total: 0,
descriptions: {},
},
],
},
],
};
},
methods: {
addTab() {
this.tabs.push({
selectedHouseType: "",
});
this.tabs[this.tabs.length - 1].rows.push({
selectedDecor: "",
selectedDes: "",
selectedQty: "",
selectedRate: "",
line_total: 0,
decorTypes: {},
});
},
addRow() {
this.tabs[this.tabs.length - 1].rows.push({
selectedDecor: "",
selectedDes: "",
selectedQty: "",
selectedRate: "",
line_total: 0,
decorTypes: {},
});
},
}
So how can I do both "add-row" and "add-tab" both separately?