I have a basic component being displayed as
<House :_people="[{'name': 'Kevin'}, {'name':'Bert'}, {'name': 'Timmy'}]"></House>
The structure of the component is like this:
<template>
<div class="house">
<ul>
<li v-for="person in people">
{{ person.name }}
</li>
</ul>
<a href="#add" @click="addMark">Add Mark</a>
</div>
</template>
<script>
export default {
props: ['_people'],
data: function(){
return {
people: this._people
}
},
methods: {
addMark: function(){
this.people.push({
name: 'Mark'
});
}
},
}
The issue arises when I need to pass a JSON payload to the initial component, which sets it as a prop rather than a data attribute. When attempting to manipulate the prop, it does not update. So, I connected the _people prop to the people attribute instead.
Is this approach appropriate? Is there something obvious that I am overlooking?