I'm in the process of creating a reviews page using Vue.js. The goal is to take an array of objects and dynamically insert a section on the page for each review in the array, displaying details like name, rating, and review text.
The current code implementation is partially functional. The data is successfully passed to Vue and all the necessary HTML structures are created on the page. However, there seems to be an issue with interpolation as the content is not being displayed within the divs.
HTML
<div class="reviews-holder" id="review-holder">
<div v-for="review of reviews" class="review-container">
<div class="row border-bottom">
<div class="col-sm-6 col-xs-12">
<h5>{{ review.name }}</h5>
<p>Reviewed on {{ review.time }}</p>
</div>
<div class="col-sm-6 col-xs-12">
<div class="pull-right rating rating-header">
{{ review.rating }}
</div>
</div>
</div>
<h4>{{ review.title }}</h4>
<span class="review-text">{{ review.review }}</span>
</div>
JS
$(document).ready(function() {
$.post("/api/getReviews", dto, function(res){
if (res.ok) {
console.log("res.res", res.res);
var reviewsVue = new Vue({
el: '#review-holder',
data: {
reviews: res.res
},
components: {
VPaginator: VuePaginator
},
methods: {
updateResource(data){
this.reviews = data
}
}
});
console.log('reviewsVue', reviewsVue);
} else {
console.log(res);
}
});
});
Below is the structure of the reviews item (res.res), filled with actual data:
[{name: , rating: , review: , time: , title:}, {name: , rating: , review: , time: , title:}]