The idea is to go through the collection of messages ( messages
) obtained from the backend through AJAX and display them in the HTML, for this use v-for
. Apparently the parameters returned by data are not receiving the template.
Template
<template lang="html">
<a v-for="message in messages" href="#">
<div class="user-img">
<img src="/assets/plugins/images/users/pawandeep.jpg" alt="user" class="img-circle">
<span class="profile-status away busy offline online pull-right"></span>
</div>
<div class="mail-contnet">
<h5 vue-text="message.title"></h5>
<span class="mail-desc">Content</span>
<span class="time">Date</span>
</div>
</a>
</template>
JavaScript
export default {
data() {
return {
messages: []
}
},
mounted() {
this
.$http.get('/api/messages')
.then(response => this.messages = response.data);
}
}