Answer the question
In order to leave comments, you need to log in
Why is an object pushed into the parent array by a reference and how to fix it?
There is a modal.vue component in it, a form with an input and a button handler. As the input fills up, the data is committed to the object:
eventDefault: {
date: ' ',
time: ' ',
title: ' ',
desc: ' '
}
pushEventToCalendar(eventDefault){
this.currentEvents.push(eventDefault)
}
Answer the question
In order to leave comments, you need to log in
1. Really it is impossible to set empty lines as values at opening of a window in any way? Or not even when re-opening, but immediately, as the values become unnecessary - after the data is transferred to the parent.
As I understand it, inputs and properties of the eventDefault object are connected via v-model
. You can make another object - with default values for inputs, and just copy its contents to eventDefault after passing the data to the parent component.
2. Pass a copy of the object to the parent component. You can copy an object like this: . Or like this: . const copy = Object.assign({}, original)
const copy = { ...original }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question