I'm trying to push a new item to an array however the DOM is not updating. I've read the Vue docs which say use Vue.set to enable reactivity for adding objects to an array. https://jsfiddle.net/exL27gvz/40/
Vue.component('team-invite-list', ({
template: '<div class="mt-2 flex"><a v-for="user in invitedUsers" :key="user.test" href="#">test</a></div>',
props: ['invitedUsers'],
methods: {
addInvitedUser: function(user) {
Vue.set(this.invitedUsers, this.invitedUsers.length, user)
}
},
mounted() {
console.log(this.invitedUsers)
this.invitedUsers.push({test: '2'})
}
}));
var vm = new Vue({
data() {
return {
};
},
mounted() {
}
}).$mount('#app');
<div id="app">
<team-invite-list :invited-users="[{test: 'test'}]"></team-invite-list>
</div>
The DOM only ever shows the value object passed in as a prop.