I have an Array that I use to populate a Dialog Vue Component. I have:
basicInfo: [{ firstName: "John" , lastName: "Doe" }],
<basicInfoForm v-model="showBasicInfoForm" :basicInfo="newbasicInfo[0]"></basicInfoForm>
on the Parent I have
{{basicInfo[0].firstName + ' ' + basicInfo[0].lastName}}
I have a button that will call a Form Component and open a Dialog popup that allows editing. My problem is that all changes to the Dialog are also immediately shown on the Parent. I would like to have on the Child Dialog a cancel button so no changes will be made. I cloned the array before I pass it:
this.newbasicInfo = this.basicInfo.slice();
and on the Child Dialog
<v-text-field
v-model="basicInfo.firstName"
label="First Name"
class="input-name styled-input"
></v-text-field>
props: {
value: Boolean,
basicInfo: Array
},
My problem is that I can see each key stroke as changes are being made so there is no way to go back to the original if a cancel is selected. I'm new to Vue and Components so I could have something totally screwed up. Why are changes being make to both the basicInfo array and the newbasicInfo array at the same time.