I have two Vue components, EventTask
and EventCard
. EventTask
has a currentEvent
object in data
, which I pass as a prop to EventCard
like so
<event-card :current-event="currentEvent" />
In EventCard, I initialise an event
data property from the currentEvent
prop, as suggested in this answer
export default {
name: 'EventCard',
props: {
currentEvent: {
type: Object,
required: false
}
},
data: function () {
return {
event: { ...this.currentEvent }
}
}
}
However, for some reason, the event
data property is not being set correctly. Here's what I see in the Vue developer tools
Notice that the currentEvent
prop is an object with a with a bunch of properties, but the event
data property is an empty object. Why is the data property not being initialised correctly from the prop?