I need to push () on the% void of VueJS and have it add another object to the array of objects it has there. But when I click the button I programmed to do this push () it just does not.
Follow the code below:
atualizar () {
axios({
method: 'get',
url: '/server/inbox'
}).then(function (response) {
console.log(response.data)
for (let e = 0; e < response.data.length; e++) {
this.emails.push(
{
remetente: response.data.remetente,
destinatario: response.data.destinatario,
assunto: response.data.assunto,
texto: response.data.texto
},
console.log('PUSH!')
)
}
})
.catch(function (err) {
console.log(err)
})
console.log('Fim!')
}
HTML:
<q-list no-border link inset-separator>
<q-item v-for="email in emails" :key="email.id">
<q-item-side icon="email"/>
<q-item-main>
<q-item-tile :label="emails.remetente">{{ email.remetente }}</q-item-tile>
<q-item-tile :sublabel="emails.assunto">{{ email.assunto }}</q-item-tile>
</q-item-main>
</q-item>
</q-list>
Are you sure this way ??
This is the method I created to push the array of objects, and I have already checked the data coming from the server and everything is fine, it is returning correctly.
If someone can help me, I thank them ...