0π
@Mill @Raffobaffo, as you have said in comments, May be the response from firebase coming after the method completes. So try using async await functions.
and itβs better to set a key something other than message.message
like this,
<div @v-for="(message,name,index) in messages" :key="index" class="incoming_msg">
methods: {
saveMessage : async function () {
//save to firestore
await db.collection("chat").add({
message: this.message,
time: new Date()
});
this.message = null;
},
fetchMessages : async function () {
await db.collection("chat")
.orderBy("time")
.onSnapshot(querySnapshot => {
let allMessages = [];
querySnapshot.forEach(doc => {
allMessages.push(doc.data());
});
this.messages = allMessages;
});
}
},
created : async function () {
await this.fetchMessages();
}
- [Vuejs]-Remove Vuex store after Electron app is uninstalled
- [Vuejs]-How to force vue to wait for async <script> to run before mounting components
Source:stackexchange.com