I'm messing around with a few vue chat libraries and I have this code:
<template>
<p>{{ this.users[0] }}</p>
</template>
<script>
export default {
data() {
return {
users: []
}
},
mounted() {
firestoreService.getAllUsers().then(({ data }) => {
data.forEach((user, i) => {
this.users[i] = user
});
})
}
</script>
Basically I have a firestore index where I store my users and on mount hook I populate the users array but for some reason vue does not see the data. Any ideas?
If I console.log
the data I can see the data in the console.
{{ users[0] }}
`, you don't need `this` in the template - however `this.users = data` is all you need – Jaromanda X Jul 05 '22 at 12:36