I am having an issue with my component data being updated. I have a component that is being used as a data object in another component's data field. The issue I am having is when I click on the submit button, the method should just take an input of firstname and lastname and update the child's search data field with it. However, it seems that while Vue is letting me push the data without errors, when I console.log afterwards I get an empty array. Can someone tell me what's going on that I am missing? Any help is much appreciated!
Here is the "child" component's (PatientSearch) code:
export default {
data: () => ({
search: [],
selected: [],
headers: [
{ text: 'Actions', value: '' },
{ text: 'Name', value: 'name' },
{ text: 'Status', value: 'status' },
],
items: [],
}),
created() {
//axios call that inserts retrieved data into items array
}
Here is the "parent" components code where child component is being used:
export default {
data: () => ({
PatientSearch,
...
}),
methods: {
submit: function() {
let searchString = this.firstname + ' ' + this.lastname;
console.log(searchString);
PatientSearch.data().search.push(searchString);
console.log('IN PARENT');
console.log(PatientSearch.data().search);
},
<template>
...
<app-layout title="Patient List" :children=PatientSearch>
</app-layout>
...
</template>